Skip to content

Commit

Permalink
refactor: Improve PostgreSQL schema handling in sync script (#45)
Browse files Browse the repository at this point in the history
- Add schema check in getCollectionColumnsSync in postgresql dialect
- Update SQL query in getCollectionColumnsSync to include schema filter in postgresql dialect
  • Loading branch information
fengluo authored May 16, 2024
1 parent 2b37085 commit c054cb6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/sql-ddl-sync/src/Dialects/postgresql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ export const dropForeignKey: IDialect['dropForeignKey'] = function (
export const getCollectionColumnsSync: IDialect['getCollectionColumnsSync'] = function (
dbdriver, name
) {
const schema = dbdriver.config.query?.search_path || dbdriver.config.query?.searchPath || 'public';
return dbdriver.execute(
getSqlQueryDialect('psql').escape(
"SELECT * FROM information_schema.columns WHERE table_name = ?;",
[name]
"SELECT * FROM information_schema.columns WHERE table_name = ? AND table_schema = ?;",
[name, schema]
)
)
}
Expand Down

0 comments on commit c054cb6

Please sign in to comment.