@stardeck-customer-apps/data-store-sdk 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/generate-types.js +23 -12
- package/dist/cli/generate-types.mjs +23 -12
- package/package.json +1 -1
|
@@ -88,18 +88,29 @@ async function introspectSchemaSnapshot(executor) {
|
|
|
88
88
|
ORDER BY tc.table_name, tc.constraint_name, ku.ordinal_position`
|
|
89
89
|
),
|
|
90
90
|
executor.query(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
// Read column pairings from pg_catalog: information_schema's
|
|
92
|
+
// constraint_column_usage is uncorrelated with key_column_usage, so
|
|
93
|
+
// joining them for a composite FK produces a cross product. Unnesting
|
|
94
|
+
// conkey/confkey together WITH ORDINALITY keeps referencing↔referenced
|
|
95
|
+
// columns paired and ordered.
|
|
96
|
+
`SELECT con.conname AS constraint_name,
|
|
97
|
+
rel.relname AS table_name,
|
|
98
|
+
att.attname AS column_name,
|
|
99
|
+
frel.relname AS referenced_table,
|
|
100
|
+
fatt.attname AS referenced_column,
|
|
101
|
+
CASE con.confdeltype WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT'
|
|
102
|
+
WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END AS delete_rule,
|
|
103
|
+
CASE con.confupdtype WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT'
|
|
104
|
+
WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END AS update_rule
|
|
105
|
+
FROM pg_constraint con
|
|
106
|
+
JOIN pg_class rel ON rel.oid = con.conrelid
|
|
107
|
+
JOIN pg_namespace ns ON ns.oid = rel.relnamespace
|
|
108
|
+
JOIN pg_class frel ON frel.oid = con.confrelid
|
|
109
|
+
JOIN LATERAL unnest(con.conkey, con.confkey) WITH ORDINALITY AS cols(conkey, confkey, ord) ON true
|
|
110
|
+
JOIN pg_attribute att ON att.attrelid = con.conrelid AND att.attnum = cols.conkey
|
|
111
|
+
JOIN pg_attribute fatt ON fatt.attrelid = con.confrelid AND fatt.attnum = cols.confkey
|
|
112
|
+
WHERE ns.nspname = 'public' AND con.contype = 'f'
|
|
113
|
+
ORDER BY rel.relname, con.conname, cols.ord`
|
|
103
114
|
),
|
|
104
115
|
executor.query(
|
|
105
116
|
`SELECT rel.relname AS table_name, con.conname AS name,
|
|
@@ -65,18 +65,29 @@ async function introspectSchemaSnapshot(executor) {
|
|
|
65
65
|
ORDER BY tc.table_name, tc.constraint_name, ku.ordinal_position`
|
|
66
66
|
),
|
|
67
67
|
executor.query(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
// Read column pairings from pg_catalog: information_schema's
|
|
69
|
+
// constraint_column_usage is uncorrelated with key_column_usage, so
|
|
70
|
+
// joining them for a composite FK produces a cross product. Unnesting
|
|
71
|
+
// conkey/confkey together WITH ORDINALITY keeps referencing↔referenced
|
|
72
|
+
// columns paired and ordered.
|
|
73
|
+
`SELECT con.conname AS constraint_name,
|
|
74
|
+
rel.relname AS table_name,
|
|
75
|
+
att.attname AS column_name,
|
|
76
|
+
frel.relname AS referenced_table,
|
|
77
|
+
fatt.attname AS referenced_column,
|
|
78
|
+
CASE con.confdeltype WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT'
|
|
79
|
+
WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END AS delete_rule,
|
|
80
|
+
CASE con.confupdtype WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT'
|
|
81
|
+
WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END AS update_rule
|
|
82
|
+
FROM pg_constraint con
|
|
83
|
+
JOIN pg_class rel ON rel.oid = con.conrelid
|
|
84
|
+
JOIN pg_namespace ns ON ns.oid = rel.relnamespace
|
|
85
|
+
JOIN pg_class frel ON frel.oid = con.confrelid
|
|
86
|
+
JOIN LATERAL unnest(con.conkey, con.confkey) WITH ORDINALITY AS cols(conkey, confkey, ord) ON true
|
|
87
|
+
JOIN pg_attribute att ON att.attrelid = con.conrelid AND att.attnum = cols.conkey
|
|
88
|
+
JOIN pg_attribute fatt ON fatt.attrelid = con.confrelid AND fatt.attnum = cols.confkey
|
|
89
|
+
WHERE ns.nspname = 'public' AND con.contype = 'f'
|
|
90
|
+
ORDER BY rel.relname, con.conname, cols.ord`
|
|
80
91
|
),
|
|
81
92
|
executor.query(
|
|
82
93
|
`SELECT rel.relname AS table_name, con.conname AS name,
|