You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- update some outdated overrides.
- update override comments to know when
was the last override.
- remove the `#column_names_from_column_numbers`
method that was generating N+1 queries.
- update related methods.
See:
- rails/rails@249c367
- rails/rails@4e0546c
- rails/rails@c93d1b0
# Copy/paste of the `#foreign_keys(table)` method adapted to return every single
89
-
# foreign key in the database.
88
+
# NOTE: Copy/paste of the `#foreign_keys(table)` method adapted
89
+
# to return every single foreign key in the database.
90
90
defall_foreign_keys
91
91
fk_info=internal_exec_query(<<~SQL,"SCHEMA")
92
92
SELECT CASE
@@ -99,14 +99,30 @@ def all_foreign_keys
99
99
THEN ''
100
100
ELSE n2.nspname || '.'
101
101
END || t2.relname AS to_table,
102
-
a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete, c.convalidated AS valid, c.condeferrable AS deferrable, c.condeferred AS deferred,
103
-
c.conkey, c.confkey, c.conrelid, c.confrelid
102
+
c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete, c.convalidated AS valid, c.condeferrable AS deferrable, c.condeferred AS deferred, c.conrelid, c.confrelid,
103
+
(
104
+
SELECT array_agg(a.attname ORDER BY idx)
105
+
FROM (
106
+
SELECT idx, c.conkey[idx] AS conkey_elem
107
+
FROM generate_subscripts(c.conkey, 1) AS idx
108
+
) indexed_conkeys
109
+
JOIN pg_attribute a ON a.attrelid = t1.oid
110
+
AND a.attnum = indexed_conkeys.conkey_elem
111
+
AND NOT a.attishidden
112
+
) AS conkey_names,
113
+
(
114
+
SELECT array_agg(a.attname ORDER BY idx)
115
+
FROM (
116
+
SELECT idx, c.confkey[idx] AS confkey_elem
117
+
FROM generate_subscripts(c.confkey, 1) AS idx
118
+
) indexed_confkeys
119
+
JOIN pg_attribute a ON a.attrelid = t2.oid
120
+
AND a.attnum = indexed_confkeys.confkey_elem
121
+
AND NOT a.attishidden
122
+
) AS confkey_names
104
123
FROM pg_constraint c
105
124
JOIN pg_class t1 ON c.conrelid = t1.oid
106
125
JOIN pg_class t2 ON c.confrelid = t2.oid
107
-
JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
108
-
JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
0 commit comments