diff --git a/src/schema/information-schema/table-list.ts b/src/schema/information-schema/table-list.ts index 54d6c0b0..768c7da5 100644 --- a/src/schema/information-schema/table-list.ts +++ b/src/schema/information-schema/table-list.ts @@ -52,7 +52,7 @@ export class TablesSchema extends ReadOnlyTable implements _ITable { } const ret = { table_catalog: 'pgmem', - table_schema: 'public', + table_schema: t.ownerSchema.name || 'public', table_name: t.name, table_type: 'BASE TABLE', self_referencing_column_name: null, diff --git a/src/tests/simple-queries.spec.ts b/src/tests/simple-queries.spec.ts index ed7db642..92c91795 100644 --- a/src/tests/simple-queries.spec.ts +++ b/src/tests/simple-queries.spec.ts @@ -269,6 +269,12 @@ describe('Simple queries', () => { .toEqual([{ hasuserstable: 0 }]); }) + it('can select info tables with table schema', () => { + none(`create schema custom_schema; + create table custom_schema.test(id text);`) + expect(many(`select table_name from information_schema.tables where table_name = 'test' and table_schema = 'custom_schema';`)) + .toEqual([{ table_name: 'test' }]); + }); it('can select info columns', () => { simpleDb();