Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: support weight decimals #16

Merged
merged 1 commit into from
Oct 26, 2024
Merged

Conversation

Judge40
Copy link
Contributor

@Judge40 Judge40 commented Oct 19, 2024

Use the shopspring/decimal library to add support for decimal weight values.

  • Change each Weight field's type to decimal.Decimal
  • Replace strconv.Atio() with decimal.NewFromString() for Weight
  • Modify SQL statements to insert the decimal value
  • Update weight inputs to allow decimal places and a min value of zero

This approach works without modifying the column type due to SQLite's type affinity. Ideally the column type would be changed to a more suitable type to better support other DBs, like PostgreSQL, in the future. However, that would require decisions to be made around migration processes, which may be better deferred until that work is undertaken.

Resolves #4

Use the `shopspring/decimal` library to add support for decimal weight
values.

 - Change each `Weight` field's type to `decimal.Decimal`
 - Replace `strconv.Atio()` with `decimal.NewFromString()` for Weight
 - Modify SQL statements to insert the decimal value
 - Update weight inputs to allow decimal places and a min value of zero

This approach works without modifying the column type due to SQLite's
type affinity. Ideally the column type would be changed to a more
suitable type to better support other DBs, like PostgreSQL, in the
future. However, that would require decisions to be made around
migration processes, which may be better deferred until that work is
undertaken.

Resolves aceberg#4
@aceberg aceberg merged commit 38a5d77 into aceberg:main Oct 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow weight field to take decimals
2 participants