Skip to content
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

u64 support #189

Open
jayvdb opened this issue Feb 5, 2024 · 2 comments
Open

u64 support #189

jayvdb opened this issue Feb 5, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jayvdb
Copy link
Collaborator

jayvdb commented Feb 5, 2024

https://github.com/Electron100/butane/blob/9377e31/butane_core/src/codegen/mod.rs#L455-L456 says

    // Future improvement: better support unsigned integers
   // here. Sqlite has no u64, though Postgres does

https://www.postgresql.org/docs/current/datatype-numeric.html bigint is the spec compliant signed 8 bytes, which can not hold a u64 without comparisons & aggregations being incorrect.

For postgres, we could use the numeric datatype, which I guess is what that comment is referring to.

For any backend that doesnt have a data type that can hold a u64, the u64 could be stored as a string, which will compare/sort correctly as long as the value is padded, and will aggregate reasonably well. We would likely want to put that impl behind a feature flag so people dont make use of the u64-as-string trick without being aware of the trade offs.

@jayvdb
Copy link
Collaborator Author

jayvdb commented Feb 5, 2024

Sample implementations for numeric datatype can be found at https://github.com/search?q=postgres+Numeric+language%3Arust&type=code . It is commonly used for storing bigdecimals. Shouldn't be too hard to add to butane.

@jayvdb
Copy link
Collaborator Author

jayvdb commented Feb 5, 2024

I quickly investigated diesel, and it doesnt appear to support u64, except for MySQL.

SeaORM has a BigUnsigned which is u64. e.g. https://github.com/SeaQL/sea-orm/blob/a349f13/sea-orm-codegen/tests/expanded_with_schema_name/rust_keyword.rs#L28 However it is also only implemented in MySQL.

@Electron100 Electron100 added the enhancement New feature or request label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants