db_schema-reader-postgres 0.2.rc1 → 0.2.rc2

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: 8b2b3ebe11fc219d52a9576207a384fa6dd8f9b6178a5a65efaadbb215c3dcd9
4
- data.tar.gz: 0fbc9926bcf4429875278c1d9b9157cf91618f6dad67c245c109fd85dbfc04e8
3
+ metadata.gz: 990b8933a3902ce9f0887944ff69f1134741987e77f059b029d5e7642b539a0a
4
+ data.tar.gz: a30df58f848726ce34b9975dad5d46de6595e697188c6443cf494f9247c85359
5
5
  SHA512:
6
- metadata.gz: 3f55b980f9ceb11448e1699da20f071dcc75cbd79c3dfee4869081f2fb1450b04d0027be2df92310082a5c54144c5ce8df27efa21cc1d9d19365a0127280512e
7
- data.tar.gz: 809c304408c6f03014db7ad5169f36f6616d3765d6e31a96f6ee6e566d3e3c963788a6df796eac373e59851cc42c0b69ae21a335ceb2f2a7399adde32d1ac1db
6
+ metadata.gz: 997f6d45571460252be0010a4e91a807b62ed3e957682867b98f5a49a23fdff364d4204b47eba6454e4c27d442b8afbe0d0f7430a14896ad8887678c295caec0
7
+ data.tar.gz: 7808d2a72bbc61df6d3a451d412bc0839147ca1255490ce81e40bca94c800dbe6153ebfb11200e89fcfe5cd0cee9ff1d301a71b1e1a75c0762cdae317eb3e573
@@ -1,7 +1,7 @@
1
1
  module DbSchema
2
2
  module Reader
3
3
  class Postgres
4
- VERSION = '0.2.rc1'
4
+ VERSION = '0.2.rc2'
5
5
  end
6
6
  end
7
7
  end
@@ -5,6 +5,13 @@ require_relative 'postgres/version'
5
5
  module DbSchema
6
6
  module Reader
7
7
  class Postgres
8
+ TABLES_QUERY = <<-SQL.freeze
9
+ SELECT table_name
10
+ FROM information_schema.tables
11
+ WHERE table_type = 'BASE TABLE'
12
+ AND table_schema = 'public'
13
+ SQL
14
+
8
15
  COLUMNS_QUERY = <<-SQL.freeze
9
16
  SELECT c.table_name,
10
17
  c.column_name AS name,
@@ -115,7 +122,7 @@ SELECT extname
115
122
  def read_tables
116
123
  checks_data, foreign_keys_data = constraints_data
117
124
 
118
- columns_data.keys.map do |table_name|
125
+ table_names.map do |table_name|
119
126
  Table.new(
120
127
  table_name.to_sym,
121
128
  columns_data[table_name],
@@ -139,6 +146,10 @@ SELECT extname
139
146
  end
140
147
 
141
148
  private
149
+ def table_names
150
+ @table_names ||= connection[TABLES_QUERY].to_a.map { |row| row[:table_name] }
151
+ end
152
+
142
153
  def columns_data
143
154
  @columns_data ||= connection[COLUMNS_QUERY].to_a.group_by do |column|
144
155
  column[:table_name]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_schema-reader-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.rc1
4
+ version: 0.2.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vsevolod Romashov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-17 00:00:00.000000000 Z
11
+ date: 2019-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel