Skip to content

Commit

Permalink
fix(PostgresGrammar): Switch from table_catalog to table_schema when …
Browse files Browse the repository at this point in the history
…referencing schema
  • Loading branch information
mjclemente authored May 12, 2023
1 parent eb76dc3 commit 8243391
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions models/Grammars/PostgresGrammar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton {
var sql = "SELECT #wrapColumn( "table_name" )# FROM #wrapTable( "information_schema.tables" )# WHERE #wrapColumn( "table_schema" )# = 'public'";
var args = [];
if ( schema != "" ) {
sql &= " AND #wrapColumn( "table_catalog" )# = ?";
sql &= " AND #wrapColumn( "table_schema" )# = ?";
args.append( schema );
}
var tablesQuery = runQuery( sql, args, options, "query" );
Expand All @@ -387,7 +387,7 @@ component extends="qb.models.Grammars.BaseGrammar" singleton {
function compileTableExists( tableName, schemaName = "" ) {
var sql = "SELECT 1 FROM #wrapTable( "information_schema.tables" )# WHERE #wrapColumn( "table_name" )# = ?";
if ( schemaName != "" ) {
sql &= " AND #wrapColumn( "table_catalog" )# = ?";
sql &= " AND #wrapColumn( "table_schema" )# = ?";
}
return sql;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/Schema/PostgresSchemaBuilderSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ component extends="tests.resources.AbstractSchemaBuilderSpec" {
}

function hasTableInSchema() {
return [ "SELECT 1 FROM ""information_schema"".""tables"" WHERE ""table_name"" = ? AND ""table_catalog"" = ?" ];
return [ "SELECT 1 FROM ""information_schema"".""tables"" WHERE ""table_name"" = ? AND ""table_schema"" = ?" ];
}

function hasColumn() {
Expand Down

0 comments on commit 8243391

Please sign in to comment.