Conversation
|
我在代码里面没有看到automigrate相关的测试内容。 |
a631807682
left a comment
There was a problem hiding this comment.
Can you add unit tests for my question?
Signed-off-by: Chise1 <[email protected]>
Signed-off-by: Chise1 <[email protected]>
a631807682
left a comment
There was a problem hiding this comment.
I think this can be a temporary solution, and the comments need to be handled later.
#7450 (comment)
#7450 (comment)
I think the specific types (decimal/numeric) should be abstracted out and handled by the driver, which may require extending the ColumnType interface
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where AutoMigrate would always emit an ALTER for decimal/numeric fields even when precision/scale hadn’t changed. It adds targeted precision checks in the migrator and a new test suite to verify correct behavior.
- Added precision-aware logic for
decimal/numericinMigrator.MigrateColumn - Introduced
TestAutoMigrateDecimaland helpers to validate no-op versus real ALTERs - Updated
go.modto bump GORM and driver versions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/migrate_test.go | Added testAutoMigrateDecimal, decimalColumnsTest, and TestAutoMigrateDecimal |
| tests/go.mod | Bumped gorm.io/gorm to v1.26.1 and related driver versions |
| migrator/migrator.go | Enhanced decimal/numeric precision detection to prevent redundant ALTERs |
Comments suppressed due to low confidence (2)
tests/migrate_test.go:2004
- [nitpick] The Go convention is to use uppercase acronyms; rename
modifySqltomodifySQLfor consistency.
var modifySql []string
tests/migrate_test.go:2028
- [nitpick] Rename
modSqltomodSQLto follow Go naming conventions for acronyms.
modSql := testAutoMigrateDecimal(t, t1, t2)
Signed-off-by: Chise1 <[email protected]>
Signed-off-by: Chise1 <[email protected]>
Signed-off-by: Chise1 <[email protected]>
# Conflicts: # tests/go.mod
Signed-off-by: Chise1 <[email protected]>
What did this pull request do?
修复automigrate无法正确识别decimal精度是否变化的问题。
User Case Description
参考issues 7449
如果有一个对象如下:
每次自动同步都会触发