specify6 icon indicating copy to clipboard operation
specify6 copied to clipboard

[Schema] Double/Float to BigDecimal observations

Open melton-jason opened this issue 4 years ago • 2 comments

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: 1234567890 is a valid number, but 12345678901 will not allow them to save the form

      • However, 1234567890.1234 is 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 1 is entered, the number will save as 1.0000000000
  • This can cause some issues if the user enters a number with more 10 digits past the decimal.

    • 0.1234567890123 will save as 0.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.
    • 00001 will get converted to 1.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) 00001 does return the correct record, but so does querying 01, or 000000000001, etc..
    • The number still displays as 1.0000000000 inside 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

melton-jason avatar Sep 27 '22 21:09 melton-jason

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.

benanhalt avatar Sep 29 '22 17:09 benanhalt

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.

benanhalt avatar Sep 29 '22 17:09 benanhalt