updateable_views_inheritance 1.5.1 → 1.7.0
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/CHANGELOG.md +4 -0
- data/Gemfile +1 -5
- data/lib/updateable_views_inheritance/postgresql_adapter.rb +18 -8
- data/lib/updateable_views_inheritance/version.rb +1 -1
- data/test/content_test.rb +3 -7
- data/test/deep_hierarchy_test.rb +4 -4
- data/test/dummy/config/application.rb +0 -6
- data/test/instantiation_test.rb +1 -2
- data/test/migration_test.rb +4 -4
- data/test/schema_test.rb +2 -2
- data/test/single_table_inheritance_test.rb +1 -1
- data/test/test_helper.rb +0 -2
- data/updateable_views_inheritance.gemspec +3 -3
- metadata +32 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cc7de06768bfaa7271e412ae2a2958b2eab9d67a82ea00f63937fee7819227e
|
4
|
+
data.tar.gz: 610d697e27f5c3a930ae3b73f9ca39d96e0306c1045d8bd7464d241612505662
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 487871f182d767012231ca8bc56167bd6365f6bed2641c3ff1d9bd9dbb6ac2e2bca0104775403c614f75091e3b25501ed4671eaad4a343c90439cc5b73e87ffe
|
7
|
+
data.tar.gz: bf8a7d7d021ba1316351ec069ba36fa0fbe42a89262b58332f629082b703b249969c52237411b446e8c0b48b5fecef4ca0892a6c84a4c583c24e785bd317d1c9
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -90,19 +90,29 @@ module ActiveRecord #:nodoc:
|
|
90
90
|
if parent
|
91
91
|
reset_pk_sequence!(parent, pk, sequence)
|
92
92
|
else
|
93
|
-
unless pk
|
93
|
+
unless pk && sequence
|
94
94
|
default_pk, default_sequence = pk_and_sequence_for(table)
|
95
|
+
|
95
96
|
pk ||= default_pk
|
96
97
|
sequence ||= default_sequence
|
97
98
|
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
99
|
+
|
100
|
+
if @logger && pk && !sequence
|
101
|
+
@logger.warn "#{table} has primary key #{pk} with no default sequence."
|
102
|
+
end
|
103
|
+
|
104
|
+
if pk && sequence
|
105
|
+
quoted_sequence = quote_table_name(sequence)
|
106
|
+
max_pk = query_value("SELECT MAX(#{quote_column_name pk}) FROM #{quote_table_name(table)}", "SCHEMA")
|
107
|
+
if max_pk.nil?
|
108
|
+
if postgresql_version >= 100000
|
109
|
+
minvalue = query_value("SELECT seqmin FROM pg_sequence WHERE seqrelid = #{quote(quoted_sequence)}::regclass", "SCHEMA")
|
110
|
+
else
|
111
|
+
minvalue = query_value("SELECT min_value FROM #{quoted_sequence}", "SCHEMA")
|
112
|
+
end
|
105
113
|
end
|
114
|
+
|
115
|
+
query_value("SELECT setval(#{quote(quoted_sequence)}, #{max_pk ? max_pk : minvalue}, #{max_pk ? true : false})", "SCHEMA")
|
106
116
|
end
|
107
117
|
end
|
108
118
|
end
|
data/test/content_test.rb
CHANGED
@@ -2,11 +2,10 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class UpdateableViewsInheritanceContentTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
|
-
ActiveRecord::
|
5
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(5)
|
6
6
|
ActiveRecord::FixtureSet.reset_cache
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
9
|
def test_find
|
11
10
|
ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :steam_locomotives)
|
12
11
|
locomotive = Locomotive.find(1)
|
@@ -33,10 +32,7 @@ class UpdateableViewsInheritanceContentTest < ActiveSupport::TestCase
|
|
33
32
|
ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :electric_locomotives)
|
34
33
|
ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :steam_locomotives)
|
35
34
|
|
36
|
-
binds = [
|
37
|
-
[ElectricLocomotive.columns.find { |c| c.name == 'max_speed'}, 120],
|
38
|
-
[ElectricLocomotive.columns.find { |c| c.name == 'name'}, 'BoBo'],
|
39
|
-
[ElectricLocomotive.columns.find { |c| c.name == 'type'}, 'ElectricLocomotive']]
|
35
|
+
binds = [40, 120, 'BoBo', 'ElectricLocomotive']
|
40
36
|
res = ActiveRecord::Base.connection.exec_query(<<-SQL, 'Test prepared statement', binds)
|
41
37
|
INSERT INTO electric_locomotives (electricity_consumption, max_speed, name, type) VALUES ($1, $2, $3, $4) RETURNING id
|
42
38
|
SQL
|
@@ -63,7 +59,7 @@ class UpdateableViewsInheritanceContentTest < ActiveSupport::TestCase
|
|
63
59
|
def test_update
|
64
60
|
ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :steam_locomotives)
|
65
61
|
steam_locomotive = Locomotive.find(1)
|
66
|
-
steam_locomotive.
|
62
|
+
steam_locomotive.update(name: 'Rocket')
|
67
63
|
steam_locomotive.reload
|
68
64
|
assert_equal 'Rocket', steam_locomotive.name
|
69
65
|
end
|
data/test/deep_hierarchy_test.rb
CHANGED
@@ -2,12 +2,12 @@ require File.join(File.dirname(__FILE__), 'test_helper')
|
|
2
2
|
|
3
3
|
class DeepHierarchyTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
|
-
ActiveRecord::
|
5
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(8)
|
6
6
|
|
7
7
|
ActiveRecord::FixtureSet.reset_cache
|
8
8
|
# order of fixtures is important for the test - last loaded should not be with max(id)
|
9
|
-
%w(boats electric_trains rack_trains steam_trains
|
10
|
-
ActiveRecord::FixtureSet.create_fixtures(
|
9
|
+
%w(boats electric_trains rack_trains steam_trains maglev_trains bicycles).each do |f|
|
10
|
+
ActiveRecord::FixtureSet.create_fixtures("#{__dir__}/fixtures/", f)
|
11
11
|
end
|
12
12
|
@connection = ActiveRecord::Base.connection
|
13
13
|
end
|
@@ -41,7 +41,7 @@ class DeepHierarchyTest < ActiveSupport::TestCase
|
|
41
41
|
|
42
42
|
def test_single_table_inheritance_deeper_hierarchy_contents
|
43
43
|
mag = MaglevTrain.first
|
44
|
-
assert_equal [mag.id, mag.name, mag.number_of_rails, mag.max_speed, mag.magnetic_field,
|
44
|
+
assert_equal [mag.id, mag.name, mag.number_of_rails, mag.max_speed, mag.magnetic_field, mag.electricity_consumption], (@connection.query("SELECT id, name, number_of_rails, max_speed, magnetic_field, electricity_consumption FROM all_vehicles WHERE id=#{mag.id}").first)
|
45
45
|
end
|
46
46
|
|
47
47
|
class OrderColumnsInAggregateView < ActiveRecord::Migration[4.2]
|
@@ -42,12 +42,6 @@ module Dummy
|
|
42
42
|
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
43
43
|
# like if you have constraints or database-specific column types
|
44
44
|
# config.active_record.schema_format = :sql
|
45
|
-
|
46
|
-
# Enable the asset pipeline
|
47
|
-
config.assets.enabled = true
|
48
|
-
|
49
|
-
# Version of your assets, change this if you want to expire all your assets
|
50
|
-
config.assets.version = '1.0'
|
51
45
|
end
|
52
46
|
end
|
53
47
|
|
data/test/instantiation_test.rb
CHANGED
@@ -2,8 +2,7 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class InstantiationTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
|
-
ActiveRecord::
|
6
|
-
|
5
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(7)
|
7
6
|
ActiveRecord::FixtureSet.reset_cache
|
8
7
|
# order of fixtures is important for the test - last loaded should not be with max(id)
|
9
8
|
%w[steam_locomotives electric_locomotives maglev_locomotives bicycles].each do |f|
|
data/test/migration_test.rb
CHANGED
@@ -7,20 +7,20 @@ class UpdateableViewsInheritanceMigrationTest < ActiveSupport::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_create_child_default
|
10
|
-
ActiveRecord::
|
10
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(2)
|
11
11
|
assert_equal %w(coal_consumption id max_speed name type water_consumption),
|
12
12
|
@connection.columns(:steam_locomotives).map{ |c| c.name }.sort
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_create_child_explicit_table
|
16
|
-
ActiveRecord::
|
16
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(3)
|
17
17
|
assert_equal %w(electricity_consumption id max_speed name type),
|
18
18
|
@connection.columns(:electric_locomotives).map{ |c| c.name }.sort
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_drop_child
|
22
|
-
ActiveRecord::
|
23
|
-
ActiveRecord::
|
22
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(3)
|
23
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(2)
|
24
24
|
assert_equal %w(steam_locomotives), @connection.views.sort
|
25
25
|
assert_equal %w(ar_internal_metadata
|
26
26
|
locomotives
|
data/test/schema_test.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class SchemaTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
|
-
ActiveRecord::
|
5
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(5)
|
6
6
|
@connection = ActiveRecord::Base.connection
|
7
7
|
end
|
8
8
|
|
@@ -273,7 +273,7 @@ class SchemaTest < ActiveSupport::TestCase
|
|
273
273
|
end
|
274
274
|
|
275
275
|
def test_rebuild_all_parent_and_children_views
|
276
|
-
ActiveRecord::
|
276
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(7)
|
277
277
|
@connection.execute "DROP VIEW all_locomotives" #FIXME: single table inheritance view should be rebuilt as well
|
278
278
|
ChangeTablesInTwoInheritanceChains.new.up
|
279
279
|
|
@@ -2,7 +2,7 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
|
4
4
|
def setup
|
5
|
-
ActiveRecord::
|
5
|
+
ActiveRecord::MigrationContext.new("#{__dir__}/fixtures/migrations").migrate(6)
|
6
6
|
# order of fixtures is important for the test - last loaded should not be with max(id)
|
7
7
|
%w(electric_locomotives maglev_locomotives steam_locomotives).each do |f|
|
8
8
|
ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', f)
|
data/test/test_helper.rb
CHANGED
@@ -33,9 +33,7 @@ require 'byebug'
|
|
33
33
|
|
34
34
|
class ActiveSupport::TestCase #:nodoc:
|
35
35
|
include ActiveRecord::TestFixtures
|
36
|
-
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
|
37
36
|
ActiveRecord::Migration.verbose = false
|
38
|
-
# self.use_transactional_fixtures = true
|
39
37
|
|
40
38
|
# def teardown
|
41
39
|
# ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/', 1)
|
@@ -18,14 +18,14 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency "activerecord",
|
21
|
+
s.add_dependency "activerecord", '>= 7', '< 8'
|
22
22
|
s.add_dependency "pg"
|
23
23
|
|
24
|
-
s.add_development_dependency 'bigdecimal', '1.3.5'
|
25
24
|
s.add_development_dependency "bundler"
|
25
|
+
s.add_development_dependency "concurrent-ruby", '1.3.4'
|
26
26
|
s.add_development_dependency "minitest"
|
27
27
|
s.add_development_dependency "minitest-reporters"
|
28
|
-
s.add_development_dependency "rails", '
|
28
|
+
s.add_development_dependency "rails", '>= 7', '< 8'
|
29
29
|
s.add_development_dependency "rake"
|
30
30
|
s.add_development_dependency "simplecov"
|
31
31
|
s.add_development_dependency "simplecov_json_formatter"
|
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
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sava Chankov
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '7'
|
21
|
+
- - "<"
|
19
22
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
23
|
+
version: '8'
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
30
|
+
version: '7'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '8'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: pg
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,33 +46,33 @@ dependencies:
|
|
40
46
|
- !ruby/object:Gem::Version
|
41
47
|
version: '0'
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
49
|
+
name: bundler
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
45
51
|
requirements:
|
46
|
-
- -
|
52
|
+
- - ">="
|
47
53
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
54
|
+
version: '0'
|
49
55
|
type: :development
|
50
56
|
prerelease: false
|
51
57
|
version_requirements: !ruby/object:Gem::Requirement
|
52
58
|
requirements:
|
53
|
-
- -
|
59
|
+
- - ">="
|
54
60
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
61
|
+
version: '0'
|
56
62
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
63
|
+
name: concurrent-ruby
|
58
64
|
requirement: !ruby/object:Gem::Requirement
|
59
65
|
requirements:
|
60
|
-
- -
|
66
|
+
- - '='
|
61
67
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
68
|
+
version: 1.3.4
|
63
69
|
type: :development
|
64
70
|
prerelease: false
|
65
71
|
version_requirements: !ruby/object:Gem::Requirement
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - '='
|
68
74
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
75
|
+
version: 1.3.4
|
70
76
|
- !ruby/object:Gem::Dependency
|
71
77
|
name: minitest
|
72
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,16 +105,22 @@ dependencies:
|
|
99
105
|
name: rails
|
100
106
|
requirement: !ruby/object:Gem::Requirement
|
101
107
|
requirements:
|
102
|
-
- - "
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '7'
|
111
|
+
- - "<"
|
103
112
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
113
|
+
version: '8'
|
105
114
|
type: :development
|
106
115
|
prerelease: false
|
107
116
|
version_requirements: !ruby/object:Gem::Requirement
|
108
117
|
requirements:
|
109
|
-
- - "
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '7'
|
121
|
+
- - "<"
|
110
122
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
123
|
+
version: '8'
|
112
124
|
- !ruby/object:Gem::Dependency
|
113
125
|
name: rake
|
114
126
|
requirement: !ruby/object:Gem::Requirement
|