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

[DAT-10093] added schema escaping to getColumns call to jdbc metadata classes #2895

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ public List<CachedRow> fastFetchQuery() throws SQLException, DatabaseException {
extract(
databaseMetaData.getColumns(
((AbstractJdbcDatabase) database).getJdbcCatalogName(catalogAndSchema),
((AbstractJdbcDatabase) database).getJdbcSchemaName(catalogAndSchema),
tableName,
escapeForLike(((AbstractJdbcDatabase) database).getJdbcSchemaName(catalogAndSchema), database),
escapeForLike(tableName, database),
SQL_FILTER_MATCH_ALL)
);
//
Expand Down Expand Up @@ -424,8 +424,9 @@ public List<CachedRow> bulkFetchQuery() throws SQLException, DatabaseException {
try {
List<CachedRow> returnList =
extract(databaseMetaData.getColumns(((AbstractJdbcDatabase) database)
.getJdbcCatalogName(catalogAndSchema), ((AbstractJdbcDatabase) database)
.getJdbcSchemaName(catalogAndSchema), SQL_FILTER_MATCH_ALL, SQL_FILTER_MATCH_ALL));
.getJdbcCatalogName(catalogAndSchema),
escapeForLike(((AbstractJdbcDatabase) database).getJdbcSchemaName(catalogAndSchema), database),
SQL_FILTER_MATCH_ALL, SQL_FILTER_MATCH_ALL));
//
// IF MARIADB
// Query to get actual data types and then map each column to its CachedRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ import liquibase.extension.testing.testsystem.DatabaseTestSystem
import liquibase.extension.testing.testsystem.TestSystemFactory
import liquibase.statement.SqlStatement
import liquibase.statement.core.RawSqlStatement
import liquibase.structure.core.Column
import liquibase.structure.core.Table
import liquibase.structure.core.View
import org.junit.Rule
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll

import java.sql.Connection

class JdbcDatabaseSnapshotTest extends Specification {

@Rule
public DatabaseTestSystem h2 = Scope.currentScope.getSingleton(TestSystemFactory).getTestSystem("h2")

@Unroll
def "getTables and getViews works with underscores in schema names"() {
def "getTables, getColumns and getViews works with underscores in schema names"() {
when:
def connection = h2.getConnection()
def db = DatabaseFactory.instance.findCorrectDatabaseImplementation(new JdbcConnection(connection))
Expand All @@ -37,6 +35,9 @@ class JdbcDatabaseSnapshotTest extends Specification {
SnapshotGeneratorFactory.instance.has(new Table(null, "TEST-SCHEMA", "TEST_TABLE"), db)
!SnapshotGeneratorFactory.instance.has(new Table(null, "TEST_SCHEMA", "TEST_TABLE"), db)

SnapshotGeneratorFactory.instance.has(new Column(Table.class,null, "TEST-SCHEMA", "TEST_TABLE", "ID"), db)
!SnapshotGeneratorFactory.instance.has(new Column(Table.class, null, "TEST_SCHEMA", "TEST_TABLE","ID"), db)

SnapshotGeneratorFactory.instance.has(new View(null, "TEST-SCHEMA", "TEST_VIEW"), db)
!SnapshotGeneratorFactory.instance.has(new View(null, "TEST_SCHEMA", "TEST_VIEW"), db)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ protected String getConnectionSchemaName() {
return null;
}

@Override
public boolean supportsSchemas() {
return true;
}

private Set<String> getDefaultReservedWords() {
/*
* List taken from
Expand Down