Skip to content

fix: Ensure to uses REAL for Decimal values#1449

Open
BobdenOs wants to merge 1 commit intomainfrom
fix/decimal-is-real
Open

fix: Ensure to uses REAL for Decimal values#1449
BobdenOs wants to merge 1 commit intomainfrom
fix/decimal-is-real

Conversation

@BobdenOs
Copy link
Contributor

Currently when using cds.Decimal values on SQLite it results in the table using NUMERIC as the column type. This type is very similar to the javascript Number type, but with one primary difference that it behaves based upon the native type of the value.

// javascript
1   / 2   // 0.5
1.0 / 2.0 // 0.5
1n  / 2n  // 0n
// C/C++
1   / 2   // 0
1.0 / 2.0 // 0.5

So SQLite has the same behavior as C, but with the dynamic typing of javascript resulting in inconsistent and unpredictable behaviors. By explicitly defining Decimal as a REAL it will behave consistently as the floating number that it is supposed to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant