Please update skapi-js to 2.2.22: negative decimal index values are fixed

We found and fixed a bug in how record indexes store negative numbers with decimals, like -1.2 or -6541.3. The server is fixed, and the records already saved with those values have been repaired. One thing is left, and it is yours: update skapi-js to 2.2.22 or later in every project, because older versions of the SDK read the corrected values wrong. It takes a minute, and the steps are below.

What went wrong

A record index can be a number, and Skapi stores it as text that sorts the same way the numbers do. That is what lets you ask for records in order, or for every record above or below a value. For a negative number with decimals, the conversion to text was wrong. Whole numbers, like -2 or 150, and positive decimals, like 1.5, were never affected.

What the bug did to a negative decimal:

You saved What went wrong
-1.2 Sorted between -1 and 0 instead of below -1, and the server read it as -0.8.
-1.5 A query for values below -1.3 did not find it.
-0.5 Lost its minus sign, and was stored as 0.5.

The index statistics that getIndexes() returns, total_number and average_number, were off by the same amounts.

What we fixed

  • The server stores negative decimals correctly now. Every new value sorts, filters and reads back exactly as you saved it.
  • Records already saved are repaired. Every stored value of -1 or below was rewritten in the correct form, and total_number and average_number were corrected with it.
  • skapi-js 2.2.22 reads the corrected form. Older versions read a repaired or newly saved negative decimal wrong: -1.2 shows up as -2.8. That is why every project should update.

Values between -1 and 0 saved before the fix could not be repaired, because the old form dropped their minus sign: a stored -0.5 is the same as a stored 0.5. If your project saves values in that range, save those records again after you update.

The range of a number index

While we were at it, a reminder of the range: a number index value can be anything from -4503599627370496 to 4503599627370496, that is plus or minus 252, decimals included. A number outside the range is refused with INVALID_PARAMETER. A number keeps about 15 to 17 significant digits in total, so the larger the whole part, the fewer decimals survive. The record form on the Database page of skapi.com and bunnyquery.com now checks the range before it saves. The Indexing guide has all the rules.

How to update the SDK

If you load Skapi with a script tag, point it at the new version:

<script src="https://cdn.jsdelivr.net/npm/skapi-js@2.2.22/dist/skapi.js"></script>

If you install it with npm:

$ npm i skapi-js@latest

Then build and deploy your project as usual. To check which version a page is running, open the browser console on it and run:

await skapi.version();

It should say 2.2.22 or later.

Thank you

Thank you for building with Skapi, and for every project, question and bug report you have sent our way. We are burning the midnight oil to give you the best backend building experience we can, and fixing a bug like this one quickly is part of that promise. Most of all, at Skapi we love to see people building with passion. Keep building, and keep showing us what you make.

← Back to all articles