pg_examiner 0.4.1 → 0.4.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 +4 -4
- data/lib/pg_examiner/result/column.rb +1 -1
- data/lib/pg_examiner/result.rb +1 -1
- data/lib/pg_examiner/version.rb +1 -1
- data/spec/extension_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -0
- data/spec/table_spec.rb +24 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 697245ba4c753820e5ebb80a41c5776db2b5251b
|
4
|
+
data.tar.gz: d363b5efac3c568c25bf2976185674c9a0473023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd7e6790209d5af475aa27d2f4309b2da294fb33e0ba58f09de18c610a2b7559e7bc1527a72b403a6e5586fb891c298cf751af727772f065dcd099fe09a6b61d
|
7
|
+
data.tar.gz: 0b4520614f4f8eeb35b12ce5810ca8a996989d29e2f41531c32a80666c9e402082f7190f8f5bf8af158f17b87fe5a8dfee1af6f862b47c6593d9ab0ec5ddfa6e
|
@@ -29,7 +29,7 @@ module PGExaminer
|
|
29
29
|
@default
|
30
30
|
else
|
31
31
|
@default_calculated = true
|
32
|
-
@default = result.pg_attrdef.find{|d| d['adrelid'] == row['attrelid']}['default'] if row['atthasdef'] == 't'
|
32
|
+
@default = result.pg_attrdef.find{|d| d['adrelid'] == row['attrelid'] && d['adnum'] == row['attnum']}['default'] if row['atthasdef'] == 't'
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/pg_examiner/result.rb
CHANGED
data/lib/pg_examiner/version.rb
CHANGED
data/spec/extension_spec.rb
CHANGED
@@ -6,13 +6,13 @@ describe PGExaminer do
|
|
6
6
|
it "should be able to examine the extensions in the db" do
|
7
7
|
result1 = examine "SELECT 1"
|
8
8
|
result1.should be_an_instance_of PGExaminer::Result
|
9
|
-
result1.extensions.map(&:name).should == ['plpgsql']
|
9
|
+
result1.extensions.map(&:name).should == ['plpgsql', 'uuid-ossp']
|
10
10
|
|
11
11
|
result2 = examine <<-SQL
|
12
12
|
CREATE EXTENSION citext;
|
13
13
|
SQL
|
14
14
|
|
15
|
-
result2.extensions.length.should ==
|
15
|
+
result2.extensions.length.should == 3
|
16
16
|
|
17
17
|
citext, plpgsql = result2.extensions # Ordered by name
|
18
18
|
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,9 @@ CONNECTION = PG::Connection.open :host => uri.host,
|
|
12
12
|
:port => uri.port || 5432,
|
13
13
|
:dbname => uri.path[1..-1]
|
14
14
|
|
15
|
+
CONNECTION.set_notice_receiver {|n| n}
|
16
|
+
CONNECTION.async_exec('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"')
|
17
|
+
|
15
18
|
RSpec.configure do |config|
|
16
19
|
config.expect_with(:rspec) { |c| c.syntax = [:expect, :should] }
|
17
20
|
|
data/spec/table_spec.rb
CHANGED
@@ -154,17 +154,36 @@ describe PGExaminer do
|
|
154
154
|
)
|
155
155
|
SQL
|
156
156
|
|
157
|
+
a.should_not == b
|
158
|
+
|
159
|
+
a.diff(b).should == {"schemas"=>{"public"=>{"tables"=>{"test_table"=>{"columns"=>{"a"=>{"type"=>{"int4"=>"text"}}}}}}}}
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should consider tables with columns that have differing defaults not equivalent" do
|
163
|
+
a = examine <<-SQL
|
164
|
+
CREATE TABLE test_table (
|
165
|
+
a uuid default uuid_generate_v4(),
|
166
|
+
b timestamptz default now()
|
167
|
+
);
|
168
|
+
SQL
|
169
|
+
|
170
|
+
b = examine <<-SQL
|
171
|
+
CREATE TABLE test_table (
|
172
|
+
a uuid default uuid_generate_v4(),
|
173
|
+
b timestamptz default now()
|
174
|
+
);
|
175
|
+
SQL
|
176
|
+
|
157
177
|
c = examine <<-SQL
|
158
178
|
CREATE TABLE test_table (
|
159
|
-
a
|
179
|
+
a uuid,
|
180
|
+
b timestamptz default now()
|
160
181
|
);
|
161
182
|
SQL
|
162
183
|
|
163
|
-
a.
|
184
|
+
a.should == b
|
164
185
|
a.should_not == c
|
165
|
-
|
166
|
-
a.diff(b).should == {"schemas"=>{"public"=>{"tables"=>{"test_table"=>{"columns"=>{"a"=>{"type"=>{"int4"=>"text"}}}}}}}}
|
167
|
-
a.diff(c).should == {"schemas"=>{"public"=>{"tables"=>{"test_table"=>{"columns"=>{"a"=>{"default"=>{nil=>"5"}}}}}}}}
|
186
|
+
a.diff(c).should == {"schemas"=>{"public"=>{"tables"=>{"test_table"=>{"columns"=>{"a"=>{"default"=>{"uuid_generate_v4()"=>nil}}}}}}}}
|
168
187
|
end
|
169
188
|
|
170
189
|
it "should consider array types as different from scalar types" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_examiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hanks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|