Skip to content

Commit

Permalink
fix ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Jan 4, 2025
1 parent 7945090 commit 466d1b6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/dialect/dialectquery/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ func (p *Postgres) GetLatestVersion(tableName string) string {
}

func (p *Postgres) TableExists(tableName string) string {
q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE tablename = '%s' )`
schemaName, tableName := parseTableIdentifier(tableName)
if schemaName != "" {
q = `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE schemaname = '%s' AND tablename = '%s' )`
q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE schemaname = '%s' AND tablename = '%s' )`
return fmt.Sprintf(q, schemaName, tableName)
}
return fmt.Sprintf(q, schemaName, tableName)
q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE tablename = '%s' )`
return fmt.Sprintf(q, tableName)
}

func parseTableIdentifier(name string) (schema, table string) {
Expand Down

0 comments on commit 466d1b6

Please sign in to comment.