Skip to content

Fix non-compiling codegen for Money columns with precision and scale#3093

Merged
Huliiiiii merged 1 commit into
SeaQL:masterfrom
sueun-dev:fix/codegen-money-precision
Jun 22, 2026
Merged

Fix non-compiling codegen for Money columns with precision and scale#3093
Huliiiiii merged 1 commit into
SeaQL:masterfrom
sueun-dev:fix/codegen-money-precision

Conversation

@sueun-dev

Copy link
Copy Markdown
Contributor

The entity generator emits non-compiling Rust for a Money column that carries precision/scale. In Column::get_col_type_attrs (sea-orm-codegen/src/entity/column.rs), the Money arm dropped the inner tuple parentheses:

ColumnType::Money(Some((p, s))) => Some(format!("Money(Some({p}, {s}))")),

so it produced column_type = "Money(Some(10, 2))". sea_query::ColumnType::Money takes Option<(u32, u32)>, so Some(10, 2) is Some called with two arguments and fails to compile:

error[E0061]: enum variant takes 1 argument but 2 arguments were supplied

The adjacent Decimal arm and the get_def path already use the nested-tuple form; this aligns Money with them:

ColumnType::Money(Some((p, s))) => Some(format!("Money(Some(({p}, {s})))")),

Also added a regression test for get_col_type_attrs covering the Money and Decimal precision/scale branch, which previously had no coverage (only Money(None) was exercised).

Tested with cargo test -p sea-orm-codegen (72 passing). The new test fails before the change and passes after.

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).
@Huliiiiii Huliiiiii merged commit 314d644 into SeaQL:master Jun 22, 2026
39 checks passed
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