Skip to content

Commit 8f8aa31

Browse files
committed
feat(tables): omit policies
1 parent b81a896 commit 8f8aa31

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
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 { columnsSql, grantsSql, primaryKeysSql, relationshipsSql, tablesSql } from './sql'
125
import { PostgresMetaResult, PostgresTable } from './types'
136

147
export default class PostgresMetaTables {
@@ -237,14 +230,12 @@ const enrichedTablesSql = `
237230
WITH tables AS (${tablesSql}),
238231
columns AS (${columnsSql}),
239232
grants AS (${grantsSql}),
240-
policies AS (${policiesSql}),
241233
primary_keys AS (${primaryKeysSql}),
242234
relationships AS (${relationshipsSql})
243235
SELECT
244236
*,
245237
${coalesceRowsToArray('columns', 'columns.table_id = tables.id')},
246238
${coalesceRowsToArray('grants', 'grants.table_id = tables.id')},
247-
${coalesceRowsToArray('policies', 'policies.table_id = tables.id')},
248239
${coalesceRowsToArray('primary_keys', 'primary_keys.table_id = tables.id')},
249240
${coalesceRowsToArray(
250241
'relationships',

Diff for: src/lib/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ export const postgresTableSchema = Type.Object({
248248
comment: Type.Union([Type.String(), Type.Null()]),
249249
columns: Type.Array(postgresColumnSchema),
250250
grants: Type.Array(postgresGrantSchema),
251-
policies: Type.Array(postgresPolicySchema),
252251
primary_keys: Type.Array(postgresPrimaryKeySchema),
253252
relationships: Type.Array(postgresRelationshipSchema),
254253
})

Diff for: test/lib/tables.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import { pgMeta } from './utils'
22

33
const cleanNondet = (x: any) => {
44
const {
5-
data: { columns, grants, policies, primary_keys, relationships, ...rest2 },
5+
data: { columns, grants, primary_keys, relationships, ...rest2 },
66
...rest1
77
} = x
88

99
return {
1010
data: {
1111
columns: columns.map(({ id, table_id, ...rest }: any) => rest),
1212
grants: grants.map(({ table_id, ...rest }: any) => rest),
13-
policies: policies.map(({ id, table_id, ...rest }: any) => rest),
1413
primary_keys: primary_keys.map(({ table_id, ...rest }: any) => rest),
1514
relationships: relationships.map(({ id, ...rest }: any) => rest),
1615
...rest2,
@@ -22,14 +21,13 @@ 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 { columns, grants, primary_keys, relationships, ...rest }: any = res.data?.find(
2625
({ name }) => name === 'users'
2726
)
2827

2928
expect({
3029
columns: columns.map(({ id, table_id, ...rest }: any) => rest),
3130
grants: grants.map(({ table_id, ...rest }: any) => rest),
32-
policies: policies.map(({ id, table_id, ...rest }: any) => rest),
3331
primary_keys: primary_keys.map(({ table_id, ...rest }: any) => rest),
3432
relationships: relationships.map(({ id, ...rest }: any) => rest),
3533
...rest,
@@ -170,7 +168,6 @@ test('list', async () => {
170168
"id": Any<Number>,
171169
"live_rows_estimate": Any<Number>,
172170
"name": "users",
173-
"policies": Array [],
174171
"primary_keys": Array [
175172
Object {
176173
"name": "id",
@@ -278,7 +275,6 @@ test('retrieve, create, update, delete', async () => {
278275
"id": Any<Number>,
279276
"live_rows_estimate": 0,
280277
"name": "test",
281-
"policies": Array [],
282278
"primary_keys": Array [],
283279
"relationships": Array [],
284280
"replica_identity": "DEFAULT",
@@ -369,7 +365,6 @@ test('retrieve, create, update, delete', async () => {
369365
"id": Any<Number>,
370366
"live_rows_estimate": 0,
371367
"name": "test",
372-
"policies": Array [],
373368
"primary_keys": Array [],
374369
"relationships": Array [],
375370
"replica_identity": "DEFAULT",
@@ -466,7 +461,6 @@ test('retrieve, create, update, delete', async () => {
466461
"id": Any<Number>,
467462
"live_rows_estimate": 0,
468463
"name": "test a",
469-
"policies": Array [],
470464
"primary_keys": Array [],
471465
"relationships": Array [],
472466
"replica_identity": "NOTHING",
@@ -557,7 +551,6 @@ test('retrieve, create, update, delete', async () => {
557551
"id": Any<Number>,
558552
"live_rows_estimate": 0,
559553
"name": "test a",
560-
"policies": Array [],
561554
"primary_keys": Array [],
562555
"relationships": Array [],
563556
"replica_identity": "NOTHING",
@@ -661,7 +654,6 @@ test('update with name unchanged', async () => {
661654
"id": Any<Number>,
662655
"live_rows_estimate": 0,
663656
"name": "t",
664-
"policies": Array [],
665657
"primary_keys": Array [],
666658
"relationships": Array [],
667659
"replica_identity": "DEFAULT",
@@ -756,7 +748,6 @@ test("allow ' in comments", async () => {
756748
"id": Any<Number>,
757749
"live_rows_estimate": 0,
758750
"name": "t",
759-
"policies": Array [],
760751
"primary_keys": Array [],
761752
"relationships": Array [],
762753
"replica_identity": "DEFAULT",
@@ -899,7 +890,6 @@ test('primary keys', async () => {
899890
"id": Any<Number>,
900891
"live_rows_estimate": Any<Number>,
901892
"name": "t",
902-
"policies": Array [],
903893
"primary_keys": Array [
904894
Object {
905895
"name": "c",

0 commit comments

Comments
 (0)