Fix non-compiling codegen for Money columns with precision and scale#3093
Merged
Merged
Conversation
get_col_type_attrs dropped the inner tuple parentheses for the Money arm, emitting column_type = "Money(Some(10, 2))", which does not compile (sea_query::ColumnType::Money takes Option<(u32, u32)>). Mirror the Decimal arm and the get_def path by emitting Money(Some((p, s))), and add a regression test for the precision/scale branch (previously only Money(None) was covered).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The entity generator emits non-compiling Rust for a
Moneycolumn that carries precision/scale. InColumn::get_col_type_attrs(sea-orm-codegen/src/entity/column.rs), theMoneyarm dropped the inner tuple parentheses:so it produced
column_type = "Money(Some(10, 2))".sea_query::ColumnType::MoneytakesOption<(u32, u32)>, soSome(10, 2)isSomecalled with two arguments and fails to compile:The adjacent
Decimalarm and theget_defpath already use the nested-tuple form; this alignsMoneywith them:Also added a regression test for
get_col_type_attrscovering theMoneyandDecimalprecision/scale branch, which previously had no coverage (onlyMoney(None)was exercised).Tested with
cargo test -p sea-orm-codegen(72 passing). The new test fails before the change and passes after.