Some gotchas

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:

1234567890123456

The output looks something like this:

1.234567890123456E15

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

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.

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:

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