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

Fix create index on Postgresql and MSSQL using wrong column names when generating a changelog #3366

Conversation

filipelautert
Copy link
Collaborator

@filipelautert filipelautert commented Oct 12, 2022

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Postgresql and MSSQL server support conditional indexes (a WHERE when creating the index). When a conditional index is exported by generate-changelog, liquibase is replacing the columns by the where condition. This fix makes sure that the columns are corrected exported.
As discussed with Nathan, implementing the "where" condition would be too specific for those databases and is currently not supported by Liquibase, thus it's being ignored.

This fix makes sure that Postgresql and MSSQL use the column name instead of FILTER_CONDITION field when snapshoting indexes (as both support partial indexes, FILTER_CONDITION brings the filter and not the function value)

Things to be aware of

  • where condition is being ignored.

Things to worry about

  • None

Additional Context

  • None

…ILTER_CONDITION field when snapshoting indexes (as both support partial indexes, FILTER_CONDITION brings the filter and not the function value)
@github-actions
Copy link

github-actions bot commented Oct 12, 2022

Unit Test Results

  4 668 files  ±  0    4 668 suites  ±0   33m 5s ⏱️ - 1m 8s
  4 625 tests +  1    4 396 ✔️ +1     229 💤 ±  0  0 ±0 
54 708 runs  +12  49 573 ✔️ +1  5 135 💤 +11  0 ±0 

Results for commit 6601cfb. ± Comparison against base commit 1fb44ca.

♻️ This comment has been updated with latest results.

break;
}
}
Assert.assertTrue("There should be a sequence column starting with function \"" + function + "\"", found);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because "sequence" is a datatype, and we are not checking anything related to sequences, this assertion would be more clear if it was changed to something like "There should be a computed column ...".

Copy link
Contributor

@XDelphiGrl XDelphiGrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR fixes a bug that caused indexes created with WHERE clauses to use the WHERE clause instead of the column name in a generated createIndex changeset. The bug, and fix, are specific to Postgres and SQL Server.

  • New integration test added.
  • Internal functional tests to change test to match new/correct behavior.
  • No additional testing required.

APPROVED

Note: The wording in the integration test assertion could be updated, but I will not block the PR from approval based on that. If you can make the change before merging, @filipelautert, that would be very helpful.

@nvoxland nvoxland merged commit c9d766a into master Nov 8, 2022
@nvoxland nvoxland deleted the 2953-conditional-index-wrongly-generated-with-cli-generate-changelog-command branch November 8, 2022 07:04
@kevin-atx kevin-atx added this to the 1NEXT milestone Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Conditional index wrongly generated with CLI generate-changelog command
5 participants