db_schema 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a6dfe3738279a4199344a79ce5bfbbb7e504d50
4
- data.tar.gz: 035b90071d29f3447ac99d79cd324b403e4838d2
3
+ metadata.gz: f262094701b7ff8ff410c8854af2676daff44f4f
4
+ data.tar.gz: 0ba850facc23b85c344314a7e1e8b567ac762e4a
5
5
  SHA512:
6
- metadata.gz: a19fa80ca01c4a3fd95983a73e58cc09628a5f453ca49fc290cfa7238e9eb136bf8de25e8ae7f8f179d9c65ff24a3e18418c6d380e9db7f351f8903cfe8d839f
7
- data.tar.gz: 1fe00c3cada2070f96d397920aa785b4ef70cc77856e0ac6818eae46f92281cfdf92d9153c3a7db978a2ad1b13919edf1f2b734331501379c133812437ba8242
6
+ metadata.gz: 6fb1c3a34728124816899da8c6f67d82d70a38a0f40228cb65fca5597db8db9984fa5490554c64f0484e4160f33da94220fc385cc4b78298c6103aad189b9a6e
7
+ data.tar.gz: daeb82268ecfa4202dee52f97d92c8f4e2c6cd01a0af5c24ebb8391f16128836137a8914b8ed752eef3a4d07a478853dc75a1315358e2bc2b51df447e9d451a1
data/README.md CHANGED
@@ -53,7 +53,7 @@ But you would lose it even with manual migrations.
53
53
  Add this line to your application's Gemfile:
54
54
 
55
55
  ``` ruby
56
- gem 'db_schema', '~> 0.1.2'
56
+ gem 'db_schema', '~> 0.1.3'
57
57
  ```
58
58
 
59
59
  And then execute:
@@ -190,22 +190,28 @@ SELECT extname
190
190
 
191
191
  private
192
192
  def index_expressions_data(indices_data)
193
- expressions_stats = indices_data.each_with_object(ids: [], max: 0) do |index_data, stats|
194
- expressions_count = index_data[:column_positions].split(' ').count('0')
193
+ all_positions, max_position = {}, 0
195
194
 
196
- if expressions_count > 0
197
- stats[:ids] << index_data[:index_oid]
198
- stats[:max] = [stats[:max], expressions_count].max
195
+ indices_data.each do |index_data|
196
+ positions = index_data[:column_positions].split(' ').map(&:to_i)
197
+ expression_positions = positions.each_index.select { |i| positions[i].zero? }
198
+
199
+ if expression_positions.any?
200
+ all_positions[index_data[:index_oid]] = expression_positions
201
+ max_position = [max_position, expression_positions.max].max
199
202
  end
200
203
  end
201
204
 
202
- if expressions_stats[:max] > 0
205
+ if all_positions.any?
203
206
  DbSchema.connection[
204
207
  EXPRESSION_INDICES_QUERY,
205
- Sequel.pg_array(expressions_stats[:ids]),
206
- Sequel.pg_array((1..expressions_stats[:max]).to_a)
207
- ].each_with_object({}) do |index_data, indices_data|
208
- indices_data[index_data[:index_id]] = index_data[:definitions]
208
+ Sequel.pg_array(all_positions.keys),
209
+ Sequel.pg_array((1..max_position.succ).to_a)
210
+ ].each_with_object({}) do |index_data, indexes_data|
211
+ index_id = index_data[:index_id]
212
+ expressions = all_positions[index_id].map { |pos| index_data[:definitions][pos] }
213
+
214
+ indexes_data[index_id] = expressions
209
215
  end
210
216
  else
211
217
  {}
@@ -1,3 +1,3 @@
1
1
  module DbSchema
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vsevolod Romashov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-07 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel