ruby-pg-extras 5.6.12 → 5.6.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5476b24620456753f9fa9d0e7c33a7f716625703e45a8ea20d50d5b12525357f
4
- data.tar.gz: eb3367adcc21d585cb5bb5afd64fd794ebaf94587a3c7b1d13f9ca3a943e94d1
3
+ metadata.gz: 76983587160dcdfb1e9cc45f5e42b1329d08f74977f5c7691c7fafeeefc61fe4
4
+ data.tar.gz: 4ed633c71a3b2f4c12be8911b73ea59b750f2e7c569c6ae9913d62cab68b45e3
5
5
  SHA512:
6
- metadata.gz: c0bc05367e4c3becf6fe5f401320948ac9a6482ac7e06795556aaedde707b80fe6befd927373500ebbe8c555f821781b6a8923a5a87010fe615f562d3f4c494c
7
- data.tar.gz: c01238058d5c1f2615d9da7f6024a63107b98083ad146a650e098a8c6cf08ca8a824cbe9a6af53934b2b8d45746535fd7168e28ddb2206ba5d93bb2db1733c1f
6
+ metadata.gz: 34423951a2e88e0c2e333e3cf2acc81aa8fd3b85eb76a410d2b6a5f195c22f584b475a9ee23585f012579c203496eee037d79889325f65b3b7d224a607fe98ac
7
+ data.tar.gz: cb3ff5a3d3ef075bd1cfe5c4604bf7dfcd821b9c11985868fa98d910213e1e767b765fe92c6acc6b1bb910d35cc12435402e97364cc26b1dacc2cd5d0212b55f
@@ -29,7 +29,8 @@ module RubyPgExtras
29
29
  unused_indexes duplicate_indexes vacuum_stats kill_all kill_pid
30
30
  pg_stat_statements_reset buffercache_stats
31
31
  buffercache_usage ssl_used connections
32
- table_schema table_foreign_keys
32
+ table_schema table_schemas
33
+ table_foreign_keys foreign_keys
33
34
  )
34
35
 
35
36
  DEFAULT_SCHEMA = ENV["PG_EXTRAS_SCHEMA"] || "public"
@@ -57,12 +58,14 @@ module RubyPgExtras
57
58
  index_cache_hit: { schema: DEFAULT_SCHEMA },
58
59
  table_cache_hit: { schema: DEFAULT_SCHEMA },
59
60
  table_size: { schema: DEFAULT_SCHEMA },
61
+ table_schemas: { schema: DEFAULT_SCHEMA },
60
62
  index_scans: { schema: DEFAULT_SCHEMA },
61
63
  cache_hit: { schema: DEFAULT_SCHEMA },
62
64
  seq_scans: { schema: DEFAULT_SCHEMA },
63
65
  table_index_scans: { schema: DEFAULT_SCHEMA },
64
66
  records_rank: { schema: DEFAULT_SCHEMA },
65
67
  tables: { schema: DEFAULT_SCHEMA },
68
+ foreign_keys: { schema: DEFAULT_SCHEMA },
66
69
  kill_pid: { pid: 0 },
67
70
  })
68
71
 
@@ -13,9 +13,12 @@ module RubyPgExtras
13
13
  all_tables
14
14
  end
15
15
 
16
+ schemas = query_module.table_schemas(in_format: :hash)
17
+ foreign_keys = query_module.foreign_keys(in_format: :hash)
18
+
16
19
  tables.reduce([]) do |agg, table|
17
- foreign_keys_info = query_module.table_foreign_keys(args: { table_name: table }, in_format: :hash)
18
- schema = query_module.table_schema(args: { table_name: table }, in_format: :hash)
20
+ schema = schemas.select { |row| row.fetch("table_name") == table }
21
+ fk_columns = foreign_keys.select { |row| row.fetch("table_name") == table }
19
22
 
20
23
  fk_columns = schema.filter_map do |row|
21
24
  if DetectFkColumn.call(row.fetch("column_name"), all_tables)
@@ -24,7 +27,7 @@ module RubyPgExtras
24
27
  end
25
28
 
26
29
  fk_columns.each do |column_name|
27
- if foreign_keys_info.none? { |row| row.fetch("column_name") == column_name }
30
+ if foreign_keys.none? { |row| row.fetch("column_name") == column_name }
28
31
  agg.push(
29
32
  {
30
33
  table: table,
@@ -14,10 +14,11 @@ module RubyPgExtras
14
14
  end
15
15
 
16
16
  indexes_info = query_module.indexes(in_format: :hash)
17
+ schemas = query_module.table_schemas(in_format: :hash)
17
18
 
18
19
  tables.reduce([]) do |agg, table|
19
20
  index_info = indexes_info.select { |row| row.fetch("tablename") == table }
20
- schema = query_module.table_schema(args: { table_name: table }, in_format: :hash)
21
+ schema = schemas.select { |row| row.fetch("table_name") == table }
21
22
 
22
23
  fk_columns = schema.filter_map do |row|
23
24
  if DetectFkColumn.call(row.fetch("column_name"), all_tables)
@@ -0,0 +1,19 @@
1
+ /* Foreign keys info for all tables */
2
+
3
+ SELECT
4
+ conrelid::regclass AS table_name,
5
+ conname AS constraint_name,
6
+ a.attname AS column_name,
7
+ confrelid::regclass AS foreign_table_name,
8
+ af.attname AS foreign_column_name
9
+ FROM
10
+ pg_constraint AS c
11
+ JOIN
12
+ pg_attribute AS a ON a.attnum = ANY(c.conkey) AND a.attrelid = c.conrelid
13
+ JOIN
14
+ pg_attribute AS af ON af.attnum = ANY(c.confkey) AND af.attrelid = c.confrelid
15
+ JOIN
16
+ pg_namespace AS n ON n.oid = c.connamespace
17
+ WHERE
18
+ c.contype = 'f'
19
+ AND n.nspname = '%{schema}';
@@ -0,0 +1,5 @@
1
+ /* Column names and types for all tables */
2
+
3
+ SELECT table_name, column_name, data_type, is_nullable, column_default
4
+ FROM information_schema.columns
5
+ WHERE table_schema = '%{schema}';
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyPgExtras
4
- VERSION = "5.6.12"
4
+ VERSION = "5.6.14"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pg-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.12
4
+ version: 5.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-13 00:00:00.000000000 Z
11
+ date: 2025-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -132,6 +132,7 @@ files:
132
132
  - lib/ruby_pg_extras/queries/db_settings.sql
133
133
  - lib/ruby_pg_extras/queries/duplicate_indexes.sql
134
134
  - lib/ruby_pg_extras/queries/extensions.sql
135
+ - lib/ruby_pg_extras/queries/foreign_keys.sql
135
136
  - lib/ruby_pg_extras/queries/index_cache_hit.sql
136
137
  - lib/ruby_pg_extras/queries/index_scans.sql
137
138
  - lib/ruby_pg_extras/queries/index_size.sql
@@ -155,6 +156,7 @@ files:
155
156
  - lib/ruby_pg_extras/queries/table_index_scans.sql
156
157
  - lib/ruby_pg_extras/queries/table_indexes_size.sql
157
158
  - lib/ruby_pg_extras/queries/table_schema.sql
159
+ - lib/ruby_pg_extras/queries/table_schemas.sql
158
160
  - lib/ruby_pg_extras/queries/table_size.sql
159
161
  - lib/ruby_pg_extras/queries/tables.sql
160
162
  - lib/ruby_pg_extras/queries/total_index_size.sql