Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(postgres-parser): use current schema name in getProperties method #18

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading