Skip to content
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

me: fix regression in enum column type diffing #3374

Merged
merged 1 commit into from
Nov 9, 2022

Commits on Nov 9, 2022

  1. me: fix regression in enum column type diffing

    This regression was reported by users in
    prisma/prisma#16180
    
    It was introduced on b6400f1 by the
    same change that caused the _other_ regression that was fixed in
    eb39236.
    
    Symptoms: enum migrations became non-idempotent in many cases, depending
    on the ordering of the migrations in the Prisma schema.
    
    In that refactoring, we started storing enum ids instead of enum names
    in `ColumnTypeFamily::Enum(_)`. That makes the `ColumntypeFamily` type
    smaller, easier to deal with with regards to ownership (`EnumId` is
    `Copy`), and ready for multi-schema, because the name can be ambiguous
    and does not carry schema information, whereas the `EnumId` does. But
    more relevant to this commit: it makes comparing two
    `ColumnTypeFamily` inaccurate _when the types come from two different
    schemas_, like in sql_schema_differ.
    
    That in turn changed the signature of `column_type_family_as_enum()`,
    leading to the differ comparing enum ids instead of enum names, which
    directly causes the false positives in diffing, because the same enum
    has a different ID in each of the two schemas. The code that caused the
    regression does not appear in b6400f1,
    it uses code that was changed there.
    
    This is also a problem with the generated implementation of PartialEq
    for ColumnTypeFamily. Since it would be a larger refactoring, we only
    deal with this where relevant (sql_schema_differ) and leave removing the
    dangerous PartialEq implementation to another PR. This is the issue:
    #3373.
    
    How could this have been caught?
    
    - Tests that check that migrations are idempotent with multiple enums,
      all used in model columns _not defined in alphabetical order_ (sad but true).
      - This chimes with the theme of us not testing with large enough
        Prisma schemas.
    - migrations-ci could have caught this. We are neglecting it at the
      moment.
    tomhoule committed Nov 9, 2022
    Configuration menu
    Copy the full SHA
    e23c254 View commit details
    Browse the repository at this point in the history