Replies: 1 comment 1 reply
-
|
I think that this is actually already kind of supported, but a little hidden. If you enable the the custom types and use strict tables, then you have a lot more built in types available: A decimal type is not among them, but you can easily define one yourself. I think I have seen a showcase of a decimal type before in some blog post, but I did not find it again. I think adding a built in decimal extension or adding a decimal type to the built in custom types would be a good idea. Until then, I would just use a custom defined type. Hope this helps you. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I see that you are working in improving the turso type system. I believe that a key feature that sqlite does not have is a decimal type.
This is critical for any application working with financial data, where the errors introduced by floating point operations are not acceptable, see for instance
https://www.moderntreasury.com/journal/floats-dont-work-for-storing-cents
[This means that using floats is bad for every app handling money data!]
Many other databases like postgresql, mariadb and duckdb support this. See
But sqlite does not! Your re-witting of sqlite from scratch gives you the opportunity to fix this!
Of course, internally you would store the data scaled as integers. But, if there were a way of telling that "this is a decimal number" in the database schema, this might help other applications for example when showing the tables in a human readable form. Or might simplify client code. avoiding conversions from scaled integers to the decimal type of the language [for instance Python has a Decimal type for this, using mpdecimal].
https://docs.python.org/3/library/decimal.html
I know that there is proposal in #5515 for adding the sqlite decimal extension, but this is not a good solution (though probably easier to implement) as storing decimal numbers as text is highly inefficient.
Beta Was this translation helpful? Give feedback.
All reactions