updateable_views_inheritance 1.4.7 → 1.4.8
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7b78d1ecf36dad960f1b6ffccb8a640cbb9e1f06a8a8c1719f25f022e040aff
|
4
|
+
data.tar.gz: 2a3f41c5bb02ca8b2907c1a563cac2c4ed06429f712fed5f3b5f6ffcd988f34c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33bbf8b1caf17c212f5f8f2712476f212cea3fd09c5d8ada27c6ee235bd1e8e65792afff98606daeb2c462756f21331f76597bc2f27dae17ecbcc90cfaa41ecc
|
7
|
+
data.tar.gz: b26957b4721cffcae777c4e9e7e7280f2a5ab2d1a008c00f551bb6c0db39fe7c6f19616570efde7d8cc8e18802d36814ce1fca80c6add8401571bc73a6e880bb
|
data/CHANGELOG.md
CHANGED
@@ -126,13 +126,23 @@ module ActiveRecord #:nodoc:
|
|
126
126
|
AND cons.contype = 'p'
|
127
127
|
AND attr.attnum = ANY(cons.conkey)
|
128
128
|
SQL
|
129
|
-
|
129
|
+
|
130
|
+
if result.nil? or result.empty?
|
130
131
|
parent = parent_table(relation)
|
131
132
|
pk_and_sequence_for(parent) if parent
|
132
133
|
else
|
133
|
-
|
134
|
-
|
134
|
+
pk = result[0]
|
135
|
+
sequence = query("SELECT pg_get_serial_sequence('#{relation}', '#{result[0]}') ")[0][0]
|
136
|
+
if sequence
|
137
|
+
# ActiveRecord expects PostgreSQL::Name object as sequence, not a string
|
138
|
+
sequence_with_schema = Utils.extract_schema_qualified_name(sequence)
|
139
|
+
[pk, sequence_with_schema]
|
140
|
+
else
|
141
|
+
[pk, nil]
|
142
|
+
end
|
135
143
|
end
|
144
|
+
rescue
|
145
|
+
nil
|
136
146
|
end
|
137
147
|
|
138
148
|
# Drops a view from the database.
|
data/test/schema_test.rb
CHANGED
@@ -7,7 +7,48 @@ class SchemaTest < ActiveSupport::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_pk_and_sequence_for
|
10
|
-
|
10
|
+
pk, seq = @connection.pk_and_sequence_for(:maglev_locomotives)
|
11
|
+
assert_equal 'id', pk
|
12
|
+
assert_equal 'public.locomotives_id_seq', seq.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
class CreateChildInSchemaWithPublicParent < ActiveRecord::Migration
|
16
|
+
def self.up
|
17
|
+
execute "CREATE SCHEMA interrail"
|
18
|
+
create_child('interrail.steam_locomotives', parent: 'locomotives') do |t|
|
19
|
+
t.decimal :interrail_water_consumption, precision: 6, scale: 2
|
20
|
+
t.decimal :interrail_coal_consumption, precision: 6, scale: 2
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_pk_and_sequence_for_child_and_parent_in_different_schemas
|
26
|
+
CreateChildInSchemaWithPublicParent.up
|
27
|
+
pk, seq = @connection.pk_and_sequence_for('interrail.steam_locomotives')
|
28
|
+
assert_equal 'id', pk
|
29
|
+
assert_equal 'public.locomotives_id_seq', seq.to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
class CreateChildInSchemaWithParentInSchema < ActiveRecord::Migration
|
33
|
+
def self.up
|
34
|
+
execute "CREATE SCHEMA interrail"
|
35
|
+
create_table 'interrail.locomotives' do |t|
|
36
|
+
t.column :interrail_name, :string
|
37
|
+
t.column :interrail_max_speed, :integer
|
38
|
+
t.column :type, :string
|
39
|
+
end
|
40
|
+
create_child('interrail.steam_locomotives', parent: 'interrail.locomotives') do |t|
|
41
|
+
t.decimal :interrail_water_consumption, precision: 6, scale: 2
|
42
|
+
t.decimal :interrail_coal_consumption, precision: 6, scale: 2
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_pk_and_sequence_for_child_and_parent_in_same_nonpublic_schema
|
48
|
+
CreateChildInSchemaWithParentInSchema.up
|
49
|
+
pk, seq = @connection.pk_and_sequence_for('interrail.steam_locomotives')
|
50
|
+
assert_equal 'id', pk
|
51
|
+
assert_equal 'interrail.locomotives_id_seq', seq.to_s
|
11
52
|
end
|
12
53
|
|
13
54
|
def test_primary_key
|
data/test/test_helper.rb
CHANGED
@@ -29,5 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_development_dependency "rake"
|
30
30
|
s.add_development_dependency "simplecov"
|
31
31
|
s.add_development_dependency "simplecov_json_formatter"
|
32
|
-
s.add_development_dependency "
|
32
|
+
s.add_development_dependency "warning"
|
33
|
+
|
33
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: updateable_views_inheritance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sava Chankov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -152,7 +152,7 @@ dependencies:
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
155
|
+
name: warning
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - ">="
|