Skip to content

Commit beeee4c

Browse files
committed
feat(tables): omit columns
1 parent b81a896 commit beeee4c

File tree

3 files changed

+2
-112
lines changed

3 files changed

+2
-112
lines changed

Diff for: src/lib/PostgresMetaTables.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import { ident, literal } from 'pg-format'
22
import { DEFAULT_SYSTEM_SCHEMAS } from './constants'
33
import { coalesceRowsToArray } from './helpers'
4-
import {
5-
columnsSql,
6-
grantsSql,
7-
policiesSql,
8-
primaryKeysSql,
9-
relationshipsSql,
10-
tablesSql,
11-
} from './sql'
4+
import { grantsSql, policiesSql, primaryKeysSql, relationshipsSql, tablesSql } from './sql'
125
import { PostgresMetaResult, PostgresTable } from './types'
136

147
export default class PostgresMetaTables {
@@ -235,14 +228,12 @@ COMMIT;`
235228

236229
const enrichedTablesSql = `
237230
WITH tables AS (${tablesSql}),
238-
columns AS (${columnsSql}),
239231
grants AS (${grantsSql}),
240232
policies AS (${policiesSql}),
241233
primary_keys AS (${primaryKeysSql}),
242234
relationships AS (${relationshipsSql})
243235
SELECT
244236
*,
245-
${coalesceRowsToArray('columns', 'columns.table_id = tables.id')},
246237
${coalesceRowsToArray('grants', 'grants.table_id = tables.id')},
247238
${coalesceRowsToArray('policies', 'policies.table_id = tables.id')},
248239
${coalesceRowsToArray('primary_keys', 'primary_keys.table_id = tables.id')},

Diff for: src/lib/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ export const postgresTableSchema = Type.Object({
246246
live_rows_estimate: Type.Integer(),
247247
dead_rows_estimate: Type.Integer(),
248248
comment: Type.Union([Type.String(), Type.Null()]),
249-
columns: Type.Array(postgresColumnSchema),
250249
grants: Type.Array(postgresGrantSchema),
251250
policies: Type.Array(postgresPolicySchema),
252251
primary_keys: Type.Array(postgresPrimaryKeySchema),

Diff for: test/lib/tables.ts

+1-101
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const cleanNondet = (x: any) => {
88

99
return {
1010
data: {
11-
columns: columns.map(({ id, table_id, ...rest }: any) => rest),
1211
grants: grants.map(({ table_id, ...rest }: any) => rest),
1312
policies: policies.map(({ id, table_id, ...rest }: any) => rest),
1413
primary_keys: primary_keys.map(({ table_id, ...rest }: any) => rest),
@@ -22,12 +21,11 @@ const cleanNondet = (x: any) => {
2221
test('list', async () => {
2322
const res = await pgMeta.tables.list()
2423

25-
const { columns, grants, policies, primary_keys, relationships, ...rest }: any = res.data?.find(
24+
const { grants, policies, primary_keys, relationships, ...rest }: any = res.data?.find(
2625
({ name }) => name === 'users'
2726
)
2827

2928
expect({
30-
columns: columns.map(({ id, table_id, ...rest }: any) => rest),
3129
grants: grants.map(({ table_id, ...rest }: any) => rest),
3230
policies: policies.map(({ id, table_id, ...rest }: any) => rest),
3331
primary_keys: primary_keys.map(({ table_id, ...rest }: any) => rest),
@@ -44,62 +42,6 @@ test('list', async () => {
4442
`
4543
Object {
4644
"bytes": Any<Number>,
47-
"columns": Array [
48-
Object {
49-
"comment": null,
50-
"data_type": "bigint",
51-
"default_value": null,
52-
"enums": Array [],
53-
"format": "int8",
54-
"identity_generation": "BY DEFAULT",
55-
"is_generated": false,
56-
"is_identity": true,
57-
"is_nullable": false,
58-
"is_unique": false,
59-
"is_updatable": true,
60-
"name": "id",
61-
"ordinal_position": 1,
62-
"schema": "public",
63-
"table": "users",
64-
},
65-
Object {
66-
"comment": null,
67-
"data_type": "text",
68-
"default_value": null,
69-
"enums": Array [],
70-
"format": "text",
71-
"identity_generation": null,
72-
"is_generated": false,
73-
"is_identity": false,
74-
"is_nullable": true,
75-
"is_unique": false,
76-
"is_updatable": true,
77-
"name": "name",
78-
"ordinal_position": 2,
79-
"schema": "public",
80-
"table": "users",
81-
},
82-
Object {
83-
"comment": null,
84-
"data_type": "USER-DEFINED",
85-
"default_value": "'ACTIVE'::user_status",
86-
"enums": Array [
87-
"ACTIVE",
88-
"INACTIVE",
89-
],
90-
"format": "user_status",
91-
"identity_generation": null,
92-
"is_generated": false,
93-
"is_identity": false,
94-
"is_nullable": true,
95-
"is_unique": false,
96-
"is_updatable": true,
97-
"name": "status",
98-
"ordinal_position": 3,
99-
"schema": "public",
100-
"table": "users",
101-
},
102-
],
10345
"comment": null,
10446
"dead_rows_estimate": Any<Number>,
10547
"grants": Array [
@@ -207,7 +149,6 @@ test('retrieve, create, update, delete', async () => {
207149
Object {
208150
"data": Object {
209151
"bytes": 0,
210-
"columns": Array [],
211152
"comment": "foo",
212153
"dead_rows_estimate": 0,
213154
"grants": Array [
@@ -298,7 +239,6 @@ test('retrieve, create, update, delete', async () => {
298239
Object {
299240
"data": Object {
300241
"bytes": 0,
301-
"columns": Array [],
302242
"comment": "foo",
303243
"dead_rows_estimate": 0,
304244
"grants": Array [
@@ -395,7 +335,6 @@ test('retrieve, create, update, delete', async () => {
395335
Object {
396336
"data": Object {
397337
"bytes": 0,
398-
"columns": Array [],
399338
"comment": "foo",
400339
"dead_rows_estimate": 0,
401340
"grants": Array [
@@ -486,7 +425,6 @@ test('retrieve, create, update, delete', async () => {
486425
Object {
487426
"data": Object {
488427
"bytes": 0,
489-
"columns": Array [],
490428
"comment": "foo",
491429
"dead_rows_estimate": 0,
492430
"grants": Array [
@@ -590,7 +528,6 @@ test('update with name unchanged', async () => {
590528
Object {
591529
"data": Object {
592530
"bytes": 0,
593-
"columns": Array [],
594531
"comment": null,
595532
"dead_rows_estimate": 0,
596533
"grants": Array [
@@ -685,7 +622,6 @@ test("allow ' in comments", async () => {
685622
Object {
686623
"data": Object {
687624
"bytes": 0,
688-
"columns": Array [],
689625
"comment": "'",
690626
"dead_rows_estimate": 0,
691627
"grants": Array [
@@ -793,42 +729,6 @@ test('primary keys', async () => {
793729
Object {
794730
"data": Object {
795731
"bytes": Any<Number>,
796-
"columns": Array [
797-
Object {
798-
"comment": null,
799-
"data_type": "bigint",
800-
"default_value": null,
801-
"enums": Array [],
802-
"format": "int8",
803-
"identity_generation": null,
804-
"is_generated": false,
805-
"is_identity": false,
806-
"is_nullable": false,
807-
"is_unique": false,
808-
"is_updatable": true,
809-
"name": "c",
810-
"ordinal_position": 1,
811-
"schema": "public",
812-
"table": "t",
813-
},
814-
Object {
815-
"comment": null,
816-
"data_type": "text",
817-
"default_value": null,
818-
"enums": Array [],
819-
"format": "text",
820-
"identity_generation": null,
821-
"is_generated": false,
822-
"is_identity": false,
823-
"is_nullable": false,
824-
"is_unique": false,
825-
"is_updatable": true,
826-
"name": "cc",
827-
"ordinal_position": 2,
828-
"schema": "public",
829-
"table": "t",
830-
},
831-
],
832732
"comment": null,
833733
"dead_rows_estimate": Any<Number>,
834734
"grants": Array [

0 commit comments

Comments
 (0)