[Schema] Double/Float to BigDecimal observations
Here are my observations while testing the new BigDecimal fields (used to be Double or Float fields) for the updated schema. At the bottom of this post, I have included a table of test cases, their results, and notes (if needed).
Field Length
- It appears the maximum amount of characters (including
.) that can be added to BigDecimal fields (by users) is 15-
However, if no decimals are added, then the user can only input 10 characters.
-
If the 10th character is a decimal, then the user can add 4 digits after the decimal
-
Note that the user can add up to 15 characters into the text box, but Specify will only allow them to save (if there are no decimals) when there is only 10 digits
-
For Example:
1234567890is a valid number, but12345678901will not allow them to save the form -
However,
1234567890.1234is a valid entry
-
-
Decimal Behavior
-
It seems as if BigDecimal fields follow a rule to always maintain a 10 digit precision after the decimal point, regardless of what the user inputted.
- For example, if
1is entered, the number will save as1.0000000000
- For example, if
-
This can cause some issues if the user enters a number with more 10 digits past the decimal.
0.1234567890123will save as0.1234567890. Specify has cut off the last 3 digits after the decimal to maintain this 10 digit decimal rule
Leading Zeros
- Any leading zeros before whole numbers seem to get cut off.
00001will get converted to1.0000000000. Specify 6 is known to mask leading zeros, so this may be the case, but I am not so sure.- Querying (using the
=operator in the QueryBuilder)00001does return the correct record, but so does querying01, or000000000001, etc.. - The number still displays as
1.0000000000inside of the QueryBuilder when it is returned
The - Operator
Note that the - operator is allowed to be typed inside of BigDecimal fields, but if there is a - operator anywhere in the field, then Specify will not allow the user to save the form.
While not a major issue, if these values are never meant to be negative, is it possible to disable typing - in the field?
Example Cases
| Data Entered | Result | Notes |
|---|---|---|
| 1 | 1.0000000000 | |
| 0.1 | 0.1000000000 | |
| 12345.54321 | 12345.5432100000 | |
| 1234567890.1234 | 1234567890.1234000000 | |
| 001 | 1.0000000000 | Cuts off leading 0s. This may just mask them, but I am not sure. Querying for equals 001 still returns the correct form, but so does querying equals 00000001. Note that 1.0000000000 is still displayed in the Query Builder |
| 0000001.1234567 | 1.1234567000 | |
| 0.1234567890123 | 0.1234567890 | Cuts off the last 3 digits. Querying equals 0.1234567890123 returns no results, and querying for equals 0.1234567890 returns the form |
| 12345678901 | (Can not save) | Although this falls within the 15 character limit, the field seems to have some rule that prevents a number that is greater than 10 digits on the whole (left) side of the decimal |
| 1234567890.1234 | 1234567890.1234000000 | Because of the 15 character limit, the user is only able to add 4 digits after the decimal. And yet to maintain the rule of always having 10 digits after the decimal, Specify adds 6 zeros when the form is saved |
| 00000200000000. | 200000000.0000000000 |
Tested in Specify 6.8.01 on Windows 11
The fields are defined as decimal(20, 10) which means 20 digits total with 10 behind the decimal point. The 15 character limit is probably imposed at the UI level.
Note that the - operator is allowed to be typed inside of BigDecimal fields, but if there is a - operator anywhere in the field, then Specify will not allow the user to save the form.
This sounds like a UI bug.