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

Escape schema/tablenames in metadata.getTables() #2398

Merged
merged 4 commits into from
Feb 14, 2022

Conversation

nvoxland
Copy link
Contributor

@nvoxland nvoxland commented Jan 24, 2022

Description

Escape _'s and %s in schema/table names used in getTables() because so that searches for a table with an _ in them won't also match tables without them, since the jdbc method uses those in LIKE operations

Fixes #1604


Dev Handoff Notes (Internal Use)

Links

Testing

Dev Verification

Replicated issue by running changelog:

    <changeSet id="1" author="example">
        <createTable tableName="testTable">
            <column name="id" type="int"/>
        </createTable>
    </changeSet>

with defaultSchemaName=test_schema and then with defaultSchemaName="test-schema" on postgresql. After those two successful updates, any future runs against defaultSchemaName=test_schema failed. NOTE: the reproduction does depend a bit on how the database returns rows back internally. I initially tried testrschema as an alternative to test_schema but it worked because test_schema came back before testrschema in the problem query.

┆Issue is synchronized with this Jira Bug by Unito

def db = DatabaseFactory.instance.findCorrectDatabaseImplementation(new JdbcConnection(connection))
db.execute([
new RawSqlStatement("create schema if not exists \"TEST_SCHEMA\""),
new RawSqlStatement("create schema if not exists \"TEST-SCHEMA\""),
Copy link
Contributor

Choose a reason for hiding this comment

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

The setup of the schemas and objects makes for a really nice, readable test validation. I wish I'd thought of this when I was doing the manual tests! :) Thanks for the test, @nvoxland.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Underscore in schemaName causes error relation "databasechangelog" already exists
3 participants