pg_conn 0.3.1 → 0.3.2

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: 8b90e77eda48e35d4577bfb9bc2f6dd553054342d22fabaec9931639a765c1eb
4
- data.tar.gz: 1fca73a204f709583e67d6b035f7d48d896b63164a8e6b06a7133fbb1c038eb2
3
+ metadata.gz: 0d6a871fc8c59801e41a734dc02c4bcac36660d5b875af54f5732112d3b09913
4
+ data.tar.gz: 52d4eb6953a43a02258b875f67fbfa8ba00e31e9972d6b4e670256dc16cd6db4
5
5
  SHA512:
6
- metadata.gz: 22b8ba44cd9b8aea11291977ea85d048f57b92627c9c67e2e306b9a398842f0af7b07b7d04c7cae86c5e0d8496904ef7a471730342ee5cc7aa476099d7f2bead
7
- data.tar.gz: 215a4d41c900604a0ee10cbf87a2d9cd6eeed676a953372073084b1c43c493fa7246084dc93c4f6e321693f84cb83ec35944a14e15579347341ad90c147eae42
6
+ metadata.gz: e588d97931b32fd8ec11d06067905526bb73f73801dbc81a3538909b73f2695c4eba8f7459bafec2ea0944180b4d92cbf36cb893f59c5e09e2c3ac91c21a065c
7
+ data.tar.gz: 4b10f5d01c02cb37a634ce93bca11464591fdddafbd1be173c8284e7039b05d792403e4106738a426fc8e53d9d6ba54f175e7e5126e2077b7fab8d14de86b263
@@ -81,13 +81,18 @@ module PgConn
81
81
  conn.values relation_list_query(schema, kind: %w(v m))
82
82
  end
83
83
 
84
- # Return a list of columns. If relation is defined, only columns from that
84
+ # Return a list of columns. If +relation+ is defined, only columns from that
85
85
  # relation are listed. Columns are returned as fully qualified names (eg.
86
86
  # "schema.relation.column")
87
87
  def list_columns(schema, relation = nil)
88
88
  conn.values column_list_query(schema, relation)
89
89
  end
90
90
 
91
+ # Like #list_columns but returns a tuple of column UID and column type
92
+ def list_column_types(schema, relation = nil)
93
+ conn.tuples column_list_type_query(schema, relation)
94
+ end
95
+
91
96
  def exist_function(schema, function, signature)
92
97
  raise NotImplementedError
93
98
  end
@@ -143,15 +148,23 @@ module PgConn
143
148
  relation_clause
144
149
  ].compact.join(" and ")
145
150
  end
151
+
152
+ def column_list_type_query(schema, relation)
153
+ relation_clause = relation ? "relname = '#{relation}'" : nil
154
+ [
155
+ %(
156
+ select '#{schema}' || '.' || c.relname || '.' || a.attname as "column",
157
+ a.atttypid::regtype::text as "type"
158
+ from pg_class c
159
+ join pg_attribute a on a.attrelid = c.oid
160
+ where relnamespace::regnamespace::text = 'public'
161
+ and a.attnum > 0
162
+ ),
163
+ relation_clause
164
+ ].compact.join(" and ")
165
+ end
146
166
  end
147
167
  end
148
168
 
149
169
 
150
170
 
151
-
152
-
153
-
154
-
155
-
156
-
157
-
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg