-
Notifications
You must be signed in to change notification settings - Fork 248
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
feat: sqlite enums #5101
feat: sqlite enums #5101
Conversation
CodSpeed Performance ReportMerging #5101 will not alter performanceComparing Summary
|
WASM Query Engine file Size
|
|
||
( | ||
Some(DefaultKind::Value(PrismaValue::Enum(prev) | PrismaValue::String(prev))), | ||
Some(DefaultKind::Value(PrismaValue::String(next) | PrismaValue::Enum(next))), | ||
) => prev == next && names_match, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a bit more context here, @jacek-prisma? Thanks.
E.g., if we change an enum to a string, do we generate a migration for it? E.g., in Postgres we want a migration.sql file, in SQLite, we don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkomyno this is for default values specifically, the reason I need to add this is that the default value derived from introspection is a String while the Prisma-level default value is derived to be an Enum, I had to modify this comparison to have that produce no diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a comment
ORM-479
Relates to prisma/prisma#2219.
Implements enums in sqlite in a way similar to Mongo, the conversions are handled in the query engine, while the migrations treats them as strings (you can transition from and to enums without migration steps).
Notes
We currently warn about breaking changes to enum schema for MySQL and PSQL, there is no such warning for SQLite, because these warnings are generated based on introspection, which we can't do in the same way for enums in SQLite (it's possible to have a similar warning but it'd need to be implemented differently, I opted not to do it to avoid additional complexity).
If the user ends up with an unknown enum in the database the queries will fail (analogous to Mongo):
SQLite behavior
Mongo behavior