Skip to content

Commit

Permalink
fix: use current_schema for postgres TableExists, if schema is unspec…
Browse files Browse the repository at this point in the history
…ified (#884)
  • Loading branch information
AndersSoee authored Jan 7, 2025
1 parent 779024d commit 4337eb2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/dialect/dialectquery/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (p *Postgres) TableExists(tableName string) string {
q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE schemaname = '%s' AND tablename = '%s' )`
return fmt.Sprintf(q, schemaName, tableName)
}
q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE tablename = '%s' )`
q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE (current_schema() IS NULL OR schemaname = current_schema()) AND tablename = '%s' )`
return fmt.Sprintf(q, tableName)
}

Expand Down

0 comments on commit 4337eb2

Please sign in to comment.