-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
ColumnDef
builder functions in sea-orm-migration
may push additional statements instead of changing them
#2337
Comments
@Rudi3 @billy1624 Possibly related to Discussion #2324 |
@Borderliner yes, looks like it's exactly that. But it may not be that straightforward to fix. As I understand it, if you wanted to validate for conflicting statements, you'd have to check the previous ones upon pushing. Not sure if that's a feasible approach. |
Am I right in thinking sea-orm defaults all columns to be non-nullable? Might it make more sense to default to whatever the target DB defaults to, and not add a I suppose this wouldn't fully get around the issue that @Rudi3 mentions though. You'd still need to handle the case where the user calls Edit: Also, thanks for the workaround! |
@devklick I'm assuming that sea-orm defaults all columns to be non-nullable atm - I haven't looked at them all, however: https://docs.rs/sea-orm-migration/1.0.1/src/sea_orm_migration/schema.rs.html#112-114 To a certain extent, it may make sense to make e.g. a string non-nullable by default - as it'll give you a string in your model. Otherwise, you'd get I might have found an easier workaround: sea_orm_migration::schema::string_null |
@Rudi3 Oh, I see, there's a With that being the case, it deffo makes sense for |
@devklick yes, looks like it works just fine as long as you use it right/don't touch it afterwards. The only problem is that it'll silently continue if a user does it wrong. |
I think this should be highlighted in docs |
Description
ColumnDef
builder functions insea-orm-migration
may push SQL additional statements instead of changing them.It looks like
string()
, for example, will addNOT NULL
by default. If you addnot_null()
, you'll get the statement twice.More problematic is
null()
, as you will getNOT NULL NULL
.This behaviour may cause other "multi-statements" that can contain contradictions, too.
Steps to Reproduce
Expected Behavior
Reproduces How Often
Is it always reproducible? yes
Workarounds
Creating the
ColumnDef
from scratch seems to work fine:Versions
The text was updated successfully, but these errors were encountered: