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 issue with incorrect schema in column exists precondition when checking using a snapshot #5795

Merged
merged 1 commit into from May 10, 2024

Conversation

mpvvliet
Copy link
Contributor

Fixes #5666

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

When checking for existence of a column using a snapshot, the schema is incorrectly included, leading to an SQL query with a null schema. Included code to explicitly use the database default schema if none is set in the precondition.
Tested this on MySQL.

Things to be aware of

Things to worry about

Additional Context

Copy link
Contributor

@MalloD12 MalloD12 left a comment

Choose a reason for hiding this comment

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

Hi @mpvvliet,

Thank you for another PR. Your code changes look good I would only do again a little suggestion asking you to do the same little refactor (extracting this piece of code in a getSchema method). Other than that, it looks ok to me.

Thanks,
Daniel.

@@ -90,7 +90,11 @@
private void checkUsingSnapshot(Database database, DatabaseChangeLog changeLog) throws PreconditionFailedException, PreconditionErrorException {
Column example = new Column();
if (StringUtil.trimToNull(getTableName()) != null) {
example.setRelation(new Table().setName(database.correctObjectName(getTableName(), Table.class)).setSchema(new Schema(getCatalogName(), getSchemaName())));
String schemaName = getSchemaName();

Check notice

Code scanning / CodeQL

Possible confusion of local and field Note

Confusing name: method
checkUsingSnapshot
also refers to field
schemaName
(without qualifying it with 'this').
@filipelautert filipelautert added this to the 1NEXT milestone May 10, 2024
@filipelautert filipelautert merged commit 837f588 into liquibase:master May 10, 2024
33 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Warning when precondition references column starting with underscore
5 participants