Skip to content

Commit

Permalink
feat(functions/system): add obj_description function
Browse files Browse the repository at this point in the history
  • Loading branch information
martini97 authored and oguimbal committed Oct 11, 2024
1 parent 1ff9cb9 commit 7de1425
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/functions/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ export const systemFunctions: FunctionDefinition[] = [
returns: Types.text(),
implementation: () => 'public',
},
{
name: 'obj_description',
args: [Types.regclass, Types.text()],
returns: Types.null,
implementation: () => null
},
]
13 changes: 13 additions & 0 deletions src/tests/simple-queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ describe('Simple queries', () => {
});


it('can select obj_description', () => {
simpleDb();
const query = `
SELECT obj_description(
('"' || "table_schema" || '"."' || "table_name" || '"')::regclass,
'pg_class'
) AS table_comment
FROM "information_schema"."tables"
WHERE ("table_schema" = 'public' AND "table_name" = 'data')`;
expect(many(query)).toEqual([{ table_comment: null }]);
});


it('can select info tables', () => {
simpleDb();
expect(many('select table_name from information_schema.tables')).toEqual([{ table_name: 'data' }]);
Expand Down

0 comments on commit 7de1425

Please sign in to comment.