fix: use current_schema for postgres TableExists, if schema is unspecified (#884)

This commit is contained in:
Anders Søe 2025-01-07 13:14:31 +01:00 committed by GitHub
parent 779024deaf
commit 4337eb2257
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)
}