Skip to content

Commit

Permalink
fix: use current schema name in getProperties method
Browse files Browse the repository at this point in the history
  • Loading branch information
czaaru authored and dziraf committed Jun 14, 2024
1 parent 1746d07 commit 94f029e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dialects/base-database.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BaseDatabaseParser {
throw new Error('Implement "getResources" method for your database parser!');
}

public async getProperties(table: string): Promise<any[]> {
public async getProperties(table: string, schemaName: string): Promise<any[]> {
throw new Error('Implement "getProperties" method for your database parser!');
}
}
6 changes: 3 additions & 3 deletions src/dialects/postgres.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export class PostgresParser extends BaseDatabaseParser {
this.connectionOptions.database,
schemaName,
tableName,
await this.getProperties(tableName),
await this.getProperties(tableName, schemaName),
);

return resourceMetadata;
Expand All @@ -137,7 +137,7 @@ export class PostgresParser extends BaseDatabaseParser {
return resources.filter(Boolean) as ResourceMetadata[];
}

public async getProperties(table: string) {
public async getProperties(table: string, schemaName: string) {
const query = this.knex
.from('information_schema.columns as col')
.select(
Expand All @@ -156,7 +156,7 @@ export class PostgresParser extends BaseDatabaseParser {
.on('tco.constraint_name', 'kcu.constraint_name')
.on('tco.constraint_schema', 'kcu.constraint_schema')
.onVal('tco.constraint_type', 'PRIMARY KEY'))
.where('col.table_schema', 'public')
.where('col.table_schema', schemaName)
.where('col.table_name', table);

const columns = await query;
Expand Down

0 comments on commit 94f029e

Please sign in to comment.