Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Zu lange Zahlen oder IDs

Fließkommazahlen

...

Numbers and numeric IDs

Numbers (in Mozilla Rhino) are always represented by 64 bit floating point numbers – there is no such thing as integers in JavaScript. Also, numbers are often implicitly converted to strings, which limits their range even more. Try this in the CSE console:

Code Block
languagejs
1234567890123456

The output looks something like this:

Code Block
1.234567890123456E15

This practically limits the use of JavaScript “integers” to 9 decimal digits!

Note

Never use JavaScript numbers to represent object IDs (OIDs) of UM objects. Always treat them as strings. A necessary conversion to NUMBER oder BIGINT will take place in UM core when creating SQL statements.

Note

Also, never use JavaScript numbers to represent monetary amounts, since floating point numbers are inherently inappropriate to handle such fix point numbers.

Mass operations

When implementing any kind of mass operation – basically everything that queries the database and forEaches through the result set – keep in mind:

  • You probably want to implement some type of pagination whenever there is the slight possibility that your result set becomes too large to handle at once.

  • When paginating to modify the result set, carefully watch whether the modification changes the result set and thus the following page you get. It’s easy to unintentionally skip every second page this way.

  • Consider emptying the cache after each commit to prevent your UM to eat up more and more RAM:

    Code Block
    languagejs
    UM.test.emptyCaches();
    
    // or more specifically:
    UM.test.emptyEntryCache();