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

fixes 4879 postgresql class-cast error in alter table rename column during migrations #4880

Merged
merged 8 commits into from
Jan 31, 2024

Commits on Jan 31, 2024

  1. Add failure test case for rename

    Rename in migration files
    Caused by: java.lang.ClassCastException: class app.cash.sqldelight.dialects.postgresql.grammar.psi.impl.PostgreSqlAlterTableRenameColumnImpl cannot be cast to class com.alecstrong.sql.psi.core.psi.mixins.ColumnDefMixin (app.cash.sqldelight.dialects.postgresql.grammar.psi.impl.PostgreSqlAlterTableRenameColumnImpl and com.alecstrong.sql.psi.core.psi.mixins.ColumnDefMixin are in unnamed module of loader 'app')
    
    `at com.alecstrong.sql.psi.core.psi.mixins.InsertStmtValuesMixin.annotate(InsertStmtValuesMixin.kt:58)`
    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    eb71e8b View commit details
    Browse the repository at this point in the history
  2. Update AlterTableRenameColumnMixin to inherit SqlColumnDefImpl

    This fixes the class cast exception so that the correct compiler annotation error messages are displayed
    
    SqlColumnAlias needs to have a parent element that implements SqlColumnDef.
    The renamed column must also copy the nullable state from the renamed column so
    that the correct nullable type is maintained after renaming
    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    340dfb6 View commit details
    Browse the repository at this point in the history
  3. Now add the migrated property name

    first migrated to alpha remains a Long not null type
    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    550fefc View commit details
    Browse the repository at this point in the history
  4. Update AlterTableRenameColumnMixin

    Revert to singleOrNulll
    copy the original column (nullable) and set the new NamedElement from the columnAlias
    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    19313ca View commit details
    Browse the repository at this point in the history
  5. AlterTableAlterColumnMixin

    fixes for AlterTableAlterColumnMixin
    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    68556c9 View commit details
    Browse the repository at this point in the history
  6. AlterTableRenameColumnMixin extends AlterTableRenameColumnMixin

    open AlterTableRenameColumnMixin, ideally we should be using this PostgreSql implementation
    This is for consistency with other PR changes
    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    69d09cf View commit details
    Browse the repository at this point in the history
  7. update test

    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    b7721cc View commit details
    Browse the repository at this point in the history
  8. Rebase changes

    griffio committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    398ca4b View commit details
    Browse the repository at this point in the history