updateable_views_inheritance 1.5.0 → 1.5.1

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: 2f91d01980fe8925967bf0ad4372fd1e8fe7dd5ce279221976dde06ab62ae405
4
- data.tar.gz: ff35d58879a312f046b560a4121bf2c8efe0e3d65cff769ccd90559031a872fd
3
+ metadata.gz: a4134e2e8c505f5ca5c6d53762497a18b168b5cb43027a121f337908d1595d5b
4
+ data.tar.gz: 7dc39d94d346f6efef8862c2482afe72d97f745b822b59b313041dcb21fb9ebc
5
5
  SHA512:
6
- metadata.gz: 5340d92a39cb5a46c12d6bae63acc02b7f1139f7f52e9b2640ec05efd04bcfb1519559567de6e1ca1f7137526276827d93a0f7d611905376202b989f3c01b703
7
- data.tar.gz: 29283b534f2fe02e503cecf6569abb3425e99cfce2a2f7180d7fc4147320a6824d60c0392bc5b4b6e436c7e9d3fd90514fd113f9d2f2cb54d5e4f9c41bda9480
6
+ metadata.gz: e50eeaa1e8e686fe94bd47f02f8109335b7f38efa94e65c108dc5e0c5dcc7509e476ee14ce3de31160673d6bcce0f540dcbf0142f774b1db7f017ed106251b15
7
+ data.tar.gz: e2e3e32f9b7e6f77c113c1d80701f6a1345a4352df0779d5cfc3f450bfe11fe04c6b65955ba07de440c4733df71ba84073294f274e6c14e4b80fda1024391208
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.5.1 (27 February 2025)
2
+
3
+ Upgrade to Rails 5.1
4
+
1
5
  ## 1.5.0 (31 January 2025)
2
6
 
3
7
  Upgrade to Rails 5
@@ -342,33 +342,37 @@ module ActiveRecord #:nodoc:
342
342
  SQL
343
343
 
344
344
  # update
345
- execute(<<~SQL)
345
+ update_rule = <<~SQL
346
346
  CREATE OR REPLACE RULE #{quote_column_name("#{child_view}_update")} AS
347
347
  ON UPDATE TO #{quote_table_name(child_view)} DO INSTEAD (
348
- #{ if parent_columns.empty?
349
- ''
350
- else
351
- "UPDATE #{parent_table}
352
- SET #{ parent_columns.map { |col| "#{quote_column_name(col)} = NEW.#{quote_column_name(col)}" }.join(', ')}
353
- WHERE #{parent_pk} = OLD.#{parent_pk};"
354
- end }
355
- #{ if child_columns.empty?
356
- ''
357
- else
358
- "UPDATE #{child_table}
359
- SET #{ child_columns.map { |col| "#{quote_column_name(col)} = NEW.#{quote_column_name(col)}" }.join(', ')}
360
- WHERE #{child_pk} = OLD.#{parent_pk}"
361
- end }
362
- )
363
348
  SQL
349
+ unless parent_columns.empty?
350
+ update_rule += <<~SQL
351
+ UPDATE #{parent_table}
352
+ SET #{parent_columns.map { |col| "#{quote_column_name(col)} = NEW.#{quote_column_name(col)}" }.join(', ')}
353
+ WHERE #{parent_pk} = OLD.#{parent_pk};
354
+ SQL
355
+ end
356
+ unless child_columns.empty?
357
+ update_rule += <<~SQL
358
+ UPDATE #{child_table}
359
+ SET #{ child_columns.map { |col| "#{quote_column_name(col)} = NEW.#{quote_column_name(col)}" }.join(', ')}
360
+ WHERE #{child_pk} = OLD.#{parent_pk}
361
+ SQL
362
+ end
363
+ update_rule += ")"
364
+ execute(update_rule)
364
365
  end
365
366
 
366
367
  def insert_returning_clause(parent_pk, child_pk, child_view)
367
- columns_cast_to_null = columns(child_view)
368
- .reject { |c| c.name == parent_pk }
369
- .map { |c| "CAST (NULL AS #{c.sql_type})" }
370
- .join(", ")
371
- "RETURNING #{child_pk}, #{columns_cast_to_null}"
368
+ columns_cast = columns(child_view).map do |c|
369
+ if c.name == parent_pk
370
+ "#{child_pk}::#{c.sql_type}"
371
+ else
372
+ "NULL::#{c.sql_type}"
373
+ end
374
+ end.join(", ")
375
+ "RETURNING #{columns_cast}"
372
376
  end
373
377
 
374
378
  def create_system_table_records(parent_relation, child_aggregate_view, child_relation)
@@ -1,3 +1,3 @@
1
1
  module UpdateableViewsInheritance
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
@@ -45,13 +45,13 @@ class DeepHierarchyTest < ActiveSupport::TestCase
45
45
  end
46
46
 
47
47
  class OrderColumnsInAggregateView < ActiveRecord::Migration[4.2]
48
- def self.up
48
+ def up
49
49
  rebuild_single_table_inheritance_view(:all_vehicles,:vehicles, %w(max_speed number_of_wheels id))
50
50
  end
51
51
  end
52
52
 
53
53
  def test_single_table_inheritance_view_order_view_columns
54
- OrderColumnsInAggregateView.up
54
+ OrderColumnsInAggregateView.new.up
55
55
  assert_equal %w(max_speed number_of_wheels id),
56
56
  (@connection.query("SELECT attname
57
57
  FROM pg_class, pg_attribute
@@ -1,5 +1,5 @@
1
1
  class AddUpdateableViewsInheritance < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  create_table(:updateable_views_inheritance, :id => false) do |t|
4
4
  t.column :parent_relation, :string
5
5
  t.column :child_aggregate_view, :string
@@ -1,5 +1,5 @@
1
1
  class CreateWithDefaultTable < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  create_table :locomotives do |t|
4
4
  t.column :name, :string
5
5
  t.column :max_speed, :integer
@@ -1,5 +1,5 @@
1
1
  class CreateWithExplicitTable < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  create_child(:electric_locomotives, :table => :raw_electric_locomotives, :parent => :locomotives) do |t|
4
4
  t.decimal :electricity_consumption, :precision => 6, :scale => 2
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class CreateDeeperHierarchy < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  create_child(:maglev_locomotives, :parent => :electric_locomotives) do |t|
4
4
  t.column :magnetic_field, :integer
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class DefaultColumnValues < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  create_child(:rack_locomotives, :parent => :locomotives) do |t|
4
4
  t.column :bidirectional, :boolean, :default => false
5
5
  t.column :narrow_gauge, :boolean, :default => true
@@ -1,5 +1,5 @@
1
1
  class SingleTableInheritanceView < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  rebuild_parent_and_children_views(:locomotives)
4
4
  create_single_table_inheritance_view(:all_locomotives,:locomotives)
5
5
  end
@@ -13,7 +13,7 @@ class SecondDeepHierarchy < ActiveRecord::Migration[4.2]
13
13
  # steam_trains rack_trains electric_trains
14
14
  # |
15
15
  # maglev_trains
16
- def self.up
16
+ def up
17
17
  create_table :vehicles do |t|
18
18
  t.column :name, :string
19
19
  t.column :vehicle_type, :string
@@ -1,5 +1,5 @@
1
1
  class SecondSingleTableInheritanceView < ActiveRecord::Migration[4.2]
2
- def self.up
2
+ def up
3
3
  rebuild_parent_and_children_views(:vehicles)
4
4
  create_single_table_inheritance_view(:all_vehicles,:vehicles)
5
5
  end
data/test/schema_test.rb CHANGED
@@ -13,7 +13,7 @@ class SchemaTest < ActiveSupport::TestCase
13
13
  end
14
14
 
15
15
  class CreateChildInSchemaWithPublicParent < ActiveRecord::Migration[4.2]
16
- def self.up
16
+ def up
17
17
  execute "CREATE SCHEMA interrail"
18
18
  create_child('interrail.steam_locomotives', parent: 'locomotives') do |t|
19
19
  t.decimal :interrail_water_consumption, precision: 6, scale: 2
@@ -23,14 +23,14 @@ class SchemaTest < ActiveSupport::TestCase
23
23
  end
24
24
 
25
25
  def test_pk_and_sequence_for_child_and_parent_in_different_schemas
26
- CreateChildInSchemaWithPublicParent.up
26
+ CreateChildInSchemaWithPublicParent.new.up
27
27
  pk, seq = @connection.pk_and_sequence_for('interrail.steam_locomotives')
28
28
  assert_equal 'id', pk
29
29
  assert_equal 'public.locomotives_id_seq', seq.to_s
30
30
  end
31
31
 
32
32
  class CreateChildInSchemaWithParentInSchema < ActiveRecord::Migration[4.2]
33
- def self.up
33
+ def up
34
34
  execute "CREATE SCHEMA interrail"
35
35
  create_table 'interrail.locomotives' do |t|
36
36
  t.column :interrail_name, :string
@@ -45,7 +45,7 @@ class SchemaTest < ActiveSupport::TestCase
45
45
  end
46
46
 
47
47
  def test_pk_and_sequence_for_child_and_parent_in_same_nonpublic_schema
48
- CreateChildInSchemaWithParentInSchema.up
48
+ CreateChildInSchemaWithParentInSchema.new.up
49
49
  pk, seq = @connection.pk_and_sequence_for('interrail.steam_locomotives')
50
50
  assert_equal 'id', pk
51
51
  assert_equal 'interrail.locomotives_id_seq', seq.to_s
@@ -65,7 +65,7 @@ class SchemaTest < ActiveSupport::TestCase
65
65
  end
66
66
 
67
67
  class ParentTableWithOnlyOneColumn < ActiveRecord::Migration[4.2]
68
- def self.up
68
+ def up
69
69
  create_table(:parent_pk_only){}
70
70
  create_table :child_data do |t|
71
71
  t.column :name, :string
@@ -80,7 +80,7 @@ class SchemaTest < ActiveSupport::TestCase
80
80
  end
81
81
 
82
82
  def test_parent_table_with_only_one_column
83
- ParentTableWithOnlyOneColumn.up
83
+ ParentTableWithOnlyOneColumn.new.up
84
84
  assert @connection.views.include?('child')
85
85
  assert_equal %w(id name), @connection.columns(:child).map{|c| c.name}.sort
86
86
  ensure
@@ -88,7 +88,7 @@ class SchemaTest < ActiveSupport::TestCase
88
88
  end
89
89
 
90
90
  class ChildTableWithOnlyOneColumn < ActiveRecord::Migration[4.2]
91
- def self.up
91
+ def up
92
92
  create_table :parent do |t|
93
93
  t.column :name, :string
94
94
  end
@@ -98,7 +98,7 @@ class SchemaTest < ActiveSupport::TestCase
98
98
  end
99
99
 
100
100
  def test_child_table_with_only_one_column
101
- ChildTableWithOnlyOneColumn.up
101
+ ChildTableWithOnlyOneColumn.new.up
102
102
  assert @connection.views.include?('child_pk_only'), "Could not create child view when child table has only one column"
103
103
  assert_equal %w(id name), @connection.columns(:child_pk_only).map{|c| c.name}.sort
104
104
  end
@@ -133,7 +133,7 @@ class SchemaTest < ActiveSupport::TestCase
133
133
  end
134
134
 
135
135
  class ChangeDefaultValueOfColumn < ActiveRecord::Migration[4.2]
136
- def self.up
136
+ def up
137
137
  remove_parent_and_children_views(:rack_locomotives)
138
138
  change_column_default(:rack_locomotives_data, :rail_system, 'Marsh')
139
139
  rebuild_parent_and_children_views(:rack_locomotives)
@@ -141,24 +141,24 @@ class SchemaTest < ActiveSupport::TestCase
141
141
  end
142
142
 
143
143
  def test_change_default_value_of_column
144
- ChangeDefaultValueOfColumn.up
144
+ ChangeDefaultValueOfColumn.new.up
145
145
  RackLocomotive.reset_column_information
146
146
  assert_equal 'Marsh', RackLocomotive.new.rail_system
147
147
  end
148
148
 
149
149
  class RemoveChildrenViews < ActiveRecord::Migration[4.2]
150
- def self.up
150
+ def up
151
151
  remove_parent_and_children_views(:locomotives)
152
152
  end
153
153
  end
154
154
 
155
155
  def test_remove_parent_and_children_views
156
- RemoveChildrenViews.up
156
+ RemoveChildrenViews.new.up
157
157
  assert @connection.views.empty?
158
158
  end
159
159
 
160
160
  class RemoveColumnInParentTable < ActiveRecord::Migration[4.2]
161
- def self.up
161
+ def up
162
162
  remove_parent_and_children_views(:locomotives)
163
163
  remove_column(:locomotives, :max_speed)
164
164
  rebuild_parent_and_children_views(:locomotives)
@@ -166,7 +166,7 @@ class SchemaTest < ActiveSupport::TestCase
166
166
  end
167
167
 
168
168
  def test_remove_column_parent_table
169
- RemoveColumnInParentTable.up
169
+ RemoveColumnInParentTable.new.up
170
170
  assert_equal %w(coal_consumption id name type water_consumption),
171
171
  @connection.columns(:steam_locomotives).map{ |c| c.name }.sort
172
172
  assert_equal %w(electricity_consumption id magnetic_field name type),
@@ -174,7 +174,7 @@ class SchemaTest < ActiveSupport::TestCase
174
174
  end
175
175
 
176
176
  class RenameColumnInParentTable < ActiveRecord::Migration[4.2]
177
- def self.up
177
+ def up
178
178
  ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :electric_locomotives)
179
179
  ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :maglev_locomotives)
180
180
  ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', :steam_locomotives)
@@ -186,7 +186,7 @@ class SchemaTest < ActiveSupport::TestCase
186
186
  end
187
187
 
188
188
  def test_rename_column_parent_table
189
- RenameColumnInParentTable.up
189
+ RenameColumnInParentTable.new.up
190
190
  assert_equal %w(coal_consumption id maximal_speed name type water_consumption),
191
191
  @connection.columns(:steam_locomotives).map{ |c| c.name }.sort
192
192
  assert_equal %w(electricity_consumption id magnetic_field maximal_speed name type),
@@ -195,14 +195,14 @@ class SchemaTest < ActiveSupport::TestCase
195
195
  end
196
196
 
197
197
  class AddColumnToParentTable < ActiveRecord::Migration[4.2]
198
- def self.up
198
+ def up
199
199
  add_column(:raw_electric_locomotives, :number_of_engines, :integer)
200
200
  rebuild_parent_and_children_views(:electric_locomotives)
201
201
  end
202
202
  end
203
203
 
204
204
  def test_add_column_to_parent_table
205
- AddColumnToParentTable.up
205
+ AddColumnToParentTable.new.up
206
206
  assert_equal %w(electricity_consumption id max_speed name number_of_engines type),
207
207
  @connection.columns(:electric_locomotives).map{ |c| c.name }.sort
208
208
  assert_equal %w(electricity_consumption id magnetic_field max_speed name number_of_engines type),
@@ -211,7 +211,7 @@ class SchemaTest < ActiveSupport::TestCase
211
211
  end
212
212
 
213
213
  class ChangeChildRelationView < ActiveRecord::Migration[4.2]
214
- def self.up
214
+ def up
215
215
  remove_parent_and_children_views(:electric_locomotives)
216
216
  rename_column(:raw_electric_locomotives, :electricity_consumption, :electric_consumption)
217
217
  rebuild_parent_and_children_views(:electric_locomotives)
@@ -219,13 +219,13 @@ class SchemaTest < ActiveSupport::TestCase
219
219
  end
220
220
 
221
221
  def test_change_child_relation_view
222
- ChangeChildRelationView.up
222
+ ChangeChildRelationView.new.up
223
223
  assert_equal %w(electric_consumption id max_speed name type),
224
224
  @connection.columns(:electric_locomotives).map{ |c| c.name }.sort
225
225
  end
226
226
 
227
227
  class ChangeColumnInChildTable < ActiveRecord::Migration[4.2]
228
- def self.up
228
+ def up
229
229
  drop_view(:steam_locomotives)
230
230
  rename_column(:steam_locomotives_data, :coal_consumption, :fuel_consumption)
231
231
  create_child_view(:locomotives, :steam_locomotives)
@@ -233,13 +233,13 @@ class SchemaTest < ActiveSupport::TestCase
233
233
  end
234
234
 
235
235
  def test_change_column_in_child_table
236
- ChangeColumnInChildTable.up
236
+ ChangeColumnInChildTable.new.up
237
237
  assert_equal %w(fuel_consumption id max_speed name type water_consumption),
238
238
  @connection.columns(:steam_locomotives).map(&:name).sort
239
239
  end
240
240
 
241
241
  class CreateChildInSchema < ActiveRecord::Migration[4.2]
242
- def self.up
242
+ def up
243
243
  execute "CREATE SCHEMA interrail"
244
244
  create_table 'interrail.locomotives' do |t|
245
245
  t.column :interrail_name, :string
@@ -254,7 +254,7 @@ class SchemaTest < ActiveSupport::TestCase
254
254
  end
255
255
 
256
256
  def test_create_child_in_schema
257
- CreateChildInSchema.up
257
+ CreateChildInSchema.new.up
258
258
  assert_equal %w[id
259
259
  interrail_coal_consumption
260
260
  interrail_max_speed
@@ -265,7 +265,7 @@ class SchemaTest < ActiveSupport::TestCase
265
265
  end
266
266
 
267
267
  class ChangeTablesInTwoInheritanceChains < ActiveRecord::Migration[4.2]
268
- def self.up
268
+ def up
269
269
  add_column(:maglev_locomotives_data, :levitation_height, :integer)
270
270
  add_column(:bicycles_data, :wheel_size, :integer)
271
271
  rebuild_all_parent_and_children_views
@@ -275,7 +275,7 @@ class SchemaTest < ActiveSupport::TestCase
275
275
  def test_rebuild_all_parent_and_children_views
276
276
  ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 7)
277
277
  @connection.execute "DROP VIEW all_locomotives" #FIXME: single table inheritance view should be rebuilt as well
278
- ChangeTablesInTwoInheritanceChains.up
278
+ ChangeTablesInTwoInheritanceChains.new.up
279
279
 
280
280
  assert @connection.columns(:maglev_locomotives).map{ |c| c.name }.include?('levitation_height'),
281
281
  "Newly added column not present in view after rebuild for 1. hierarchy"
@@ -284,7 +284,7 @@ class SchemaTest < ActiveSupport::TestCase
284
284
  end
285
285
 
286
286
  class UseExistingTable < ActiveRecord::Migration[4.2]
287
- def self.up
287
+ def up
288
288
  create_table :tbl_diesel_locomotives do |t|
289
289
  t.belongs_to :locomotives
290
290
  t.integer :num_cylinders
@@ -297,12 +297,12 @@ class SchemaTest < ActiveSupport::TestCase
297
297
  end
298
298
 
299
299
  def test_skip_creating_child_table
300
- UseExistingTable.up
300
+ UseExistingTable.new.up
301
301
  assert @connection.columns(:diesel_locomotives).map(&:name).include?("num_cylinders")
302
302
  end
303
303
 
304
304
  class ReservedSQLWords < ActiveRecord::Migration[4.2]
305
- def self.up
305
+ def up
306
306
  create_child(:table, parent: :locomotives) do |t|
307
307
  t.integer :column
308
308
  end
@@ -313,14 +313,14 @@ class SchemaTest < ActiveSupport::TestCase
313
313
  end
314
314
 
315
315
  def test_reserved_words_in_tables_and_columns
316
- ReservedSQLWords.up
316
+ ReservedSQLWords.new.up
317
317
  assert @connection.columns(:table).map(&:name).include?("column")
318
318
  ensure
319
319
  ReservedSQLWords.down
320
320
  end
321
321
 
322
322
  class ChildTableIsActuallyView < ActiveRecord::Migration[4.2]
323
- def self.up
323
+ def up
324
324
  execute <<-SQL.squish
325
325
  CREATE VIEW punk_locomotives_data AS (
326
326
  SELECT steam_locomotives.id,
@@ -342,7 +342,7 @@ class SchemaTest < ActiveSupport::TestCase
342
342
  end
343
343
 
344
344
  def test_child_table_is_view
345
- ChildTableIsActuallyView.up
345
+ ChildTableIsActuallyView.new.up
346
346
  assert_equal @connection.columns(:punk_locomotives).map(&:name).sort,
347
347
  %w(coal electro id max_speed name type)
348
348
  end
@@ -31,7 +31,7 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
31
31
  end
32
32
 
33
33
  class AddColumnToParentTable < ActiveRecord::Migration[4.2]
34
- def self.up
34
+ def up
35
35
  add_column(:raw_electric_locomotives, :number_of_engines, :integer)
36
36
  drop_view(:all_locomotives)
37
37
  rebuild_parent_and_children_views(:electric_locomotives)
@@ -40,13 +40,13 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
40
40
  end
41
41
 
42
42
  def test_single_table_inheritance_view_add_column_to_parent_table
43
- AddColumnToParentTable.up
43
+ AddColumnToParentTable.new.up
44
44
  assert_equal %w(coal_consumption id max_speed name type water_consumption electricity_consumption bidirectional narrow_gauge magnetic_field rail_system number_of_engines).sort,
45
45
  @connection.columns(:all_locomotives).map{ |c| c.name }.sort
46
46
  end
47
47
 
48
48
  class RemoveColumnInParentTable < ActiveRecord::Migration[4.2]
49
- def self.up
49
+ def up
50
50
  drop_view(:all_locomotives)
51
51
  remove_parent_and_children_views(:locomotives)
52
52
  remove_column(:locomotives, :max_speed)
@@ -56,13 +56,13 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
56
56
  end
57
57
 
58
58
  def test_single_table_inheritance_view_remove_column_parent_table
59
- RemoveColumnInParentTable.up
59
+ RemoveColumnInParentTable.new.up
60
60
  assert_equal %w(coal_consumption id name type water_consumption electricity_consumption bidirectional narrow_gauge magnetic_field rail_system).sort,
61
61
  @connection.columns(:all_locomotives).map{ |c| c.name }.sort
62
62
  end
63
63
 
64
64
  class RenameColumnInParentTable < ActiveRecord::Migration[4.2]
65
- def self.up
65
+ def up
66
66
  drop_view(:all_locomotives)
67
67
  remove_parent_and_children_views(:locomotives)
68
68
  rename_column(:locomotives, :max_speed, :maximal_speed)
@@ -72,13 +72,13 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
72
72
  end
73
73
 
74
74
  def test_single_table_inheritance_view_rename_column_parent_table
75
- RenameColumnInParentTable.up
75
+ RenameColumnInParentTable.new.up
76
76
  assert_equal %w(coal_consumption id maximal_speed name type water_consumption electricity_consumption bidirectional narrow_gauge magnetic_field rail_system).sort,
77
77
  @connection.columns(:all_locomotives).map{ |c| c.name }.sort
78
78
  end
79
79
 
80
80
  class ChangeChildRelationView < ActiveRecord::Migration[4.2]
81
- def self.up
81
+ def up
82
82
  drop_view(:all_locomotives)
83
83
  remove_parent_and_children_views(:electric_locomotives)
84
84
  rename_column(:raw_electric_locomotives, :electricity_consumption, :electric_consumption)
@@ -88,13 +88,13 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
88
88
  end
89
89
 
90
90
  def test_single_table_inheritance_view_change_child_relation_view
91
- ChangeChildRelationView.up
91
+ ChangeChildRelationView.new.up
92
92
  assert_equal %w(coal_consumption id max_speed name type water_consumption electric_consumption bidirectional narrow_gauge magnetic_field rail_system).sort,
93
93
  @connection.columns(:all_locomotives).map{ |c| c.name }.sort
94
94
  end
95
95
 
96
96
  class ConflictColumns < ActiveRecord::Migration[4.2]
97
- def self.up
97
+ def up
98
98
  drop_view(:all_locomotives)
99
99
  add_column(:raw_electric_locomotives, :number_of_engines, :integer)
100
100
  add_column(:steam_locomotives_data, :number_of_engines, :string)
@@ -105,14 +105,14 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
105
105
  end
106
106
 
107
107
  def test_single_table_inheritance_view_conflict_columns
108
- ConflictColumns.up
108
+ ConflictColumns.new.up
109
109
  assert_equal %w(coal_consumption id max_speed name type water_consumption electricity_consumption bidirectional narrow_gauge magnetic_field rail_system number_of_engines).sort,
110
110
  @connection.columns(:all_locomotives).map{ |c| c.name }.sort
111
111
  assert_equal 'text', @connection.columns(:all_locomotives).detect{|c| c.name == "number_of_engines"}.sql_type
112
112
  end
113
113
 
114
114
  class ConflictColumnsWithValues < ActiveRecord::Migration[4.2]
115
- def self.up
115
+ def up
116
116
  add_column(:raw_electric_locomotives, :number_of_engines, :integer)
117
117
  add_column(:steam_locomotives_data, :number_of_engines, :string)
118
118
  execute("UPDATE raw_electric_locomotives SET number_of_engines = 2")
@@ -126,7 +126,7 @@ class SingleTableInheritanceAggregateViewTest < ActiveSupport::TestCase
126
126
 
127
127
  # FIXME: flaky test_single_table_inheritance_view_conflict_columns_with_values
128
128
  # def test_single_table_inheritance_view_conflict_columns_with_values
129
- # ConflictColumnsWithValues.up
129
+ # ConflictColumnsWithValues.new.up
130
130
  # ::SteamLocomotive.reset_column_information
131
131
  # ::ElectricLocomotive.reset_column_information
132
132
  # assert_equal %w(coal_consumption id max_speed name type water_consumption electricity_consumption bidirectional narrow_gauge magnetic_field rail_system number_of_engines).sort,
@@ -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", "~> 5.0.7"
21
+ s.add_dependency "activerecord", "~> 5.1.7"
22
22
  s.add_dependency "pg"
23
23
 
24
24
  s.add_development_dependency 'bigdecimal', '1.3.5'
25
25
  s.add_development_dependency "bundler"
26
26
  s.add_development_dependency "minitest"
27
27
  s.add_development_dependency "minitest-reporters"
28
- s.add_development_dependency "rails", '~> 5.0.7'
28
+ s.add_development_dependency "rails", '~> 5.1.7'
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.5.0
4
+ version: 1.5.1
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: 2025-01-31 00:00:00.000000000 Z
12
+ date: 2025-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 5.0.7
20
+ version: 5.1.7
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 5.0.7
27
+ version: 5.1.7
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: pg
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 5.0.7
104
+ version: 5.1.7
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 5.0.7
111
+ version: 5.1.7
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rake
114
114
  requirement: !ruby/object:Gem::Requirement