Skip to content

Add Money type support to mssql #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 5, 2025
Merged

Add Money type support to mssql #26

merged 5 commits into from
Jun 5, 2025

Conversation

c5soft
Copy link

@c5soft c5soft commented Jun 5, 2025

In MSSQL, the MONEY and SMALLMONEY types are specialized variants of DECIMAL with fixed decimal precision:
MONEY is equivalent to DECIMAL(19,4) (19 total digits with 4 decimal places)
SMALLMONEY corresponds to DECIMAL(10,4) (10 total digits with 4 decimal places)
When mapping these to Rust, the most suitable data types are rust_decimal or bigdecimal to preserve exact precision without floating-point errors.
In financial software development, the MONEY data type is widely used. Therefore, we strongly recommend adding support for the MONEY type in sqlx-oldapi.
This PR extracts shared codes into decimal_tools.rs included with testing code.

Copy link
Collaborator

@lovasoa lovasoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added tests and fixed a bug with decoding large values. When the tests pass, we can merge

@lovasoa lovasoa merged commit 6d22180 into sqlpage:main Jun 5, 2025
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.

2 participants