updateable_views_inheritance 1.4.4 → 1.4.5

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: 5a592cb214e5825bb4af87c5412ae3f91730d0e3882931f71bd16378ace7640a
4
- data.tar.gz: 2fbf14052dde92e69724d574c0b5fb7b4d79297928220bc8bee5851cc8ee60ad
3
+ metadata.gz: 8712364c9596c4bf050aeac6f2c6471d180d9a4fccec891b4e1b65e3d80d6d9b
4
+ data.tar.gz: 6b5fa6ac3a504c659a22da83717099976848d8e0499282daa6bf276b1b4766bb
5
5
  SHA512:
6
- metadata.gz: b4da55b7632575a0fba84248130308890f56dd726e6aaec835d3423b874a959d88ecf51dbf482795ba97869e5255411b9599b0117df61c6e70b3f095322c23fe
7
- data.tar.gz: edd29da257c91e7d8a53df032bc70dd2317c78433637649e23285118b058109116259ed22efc86b8495f44301c5c6831c125e26565c1aa203ad00663205c8f6c
6
+ metadata.gz: 735b84529fa5855434e025cf1f22015af66f00d098284f9492b2b06529872478b478732f44b72442e4c30660b7b4a919a4bfe99cda357967a2d00af2fb915716
7
+ data.tar.gz: ced8b499fe12b8451f0c8c1caf00aacb2cea83e2858279cf3c126e8241fbf3fc038d80f1256ad817762963ed6701c79bcfc2b5ff15c0abdeaf794ccbfeb35dbc
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 1.4.4 (09 October 2024)
1
+ ## 1.4.5 (09 October 2024)
2
2
 
3
3
  Bugfixes:
4
4
 
@@ -305,7 +305,7 @@ module ActiveRecord #:nodoc:
305
305
  def do_create_child_view(parent_table, parent_columns, parent_pk, child_view, child_columns, child_pk, child_table)
306
306
  view_columns = parent_columns + child_columns
307
307
  execute(<<~SQL)
308
- CREATE OR REPLACE VIEW #{quote_column_name(child_view)} AS (
308
+ CREATE OR REPLACE VIEW #{quote_table_name(child_view)} AS (
309
309
  SELECT parent.#{parent_pk},
310
310
  #{ view_columns.map { |col| quote_column_name(col) }.join(",") }
311
311
  FROM #{parent_table} parent
@@ -322,7 +322,7 @@ module ActiveRecord #:nodoc:
322
322
  # Setting the sequence to its value (explicitly supplied or the default) covers both cases.
323
323
  execute(<<~SQL)
324
324
  CREATE OR REPLACE RULE #{quote_column_name("#{child_view}_insert")} AS
325
- ON INSERT TO #{quote_column_name(child_view)} DO INSTEAD (
325
+ ON INSERT TO #{quote_table_name(child_view)} DO INSTEAD (
326
326
  INSERT INTO #{parent_table}
327
327
  ( #{ [parent_pk, parent_columns].flatten.map { |col| quote_column_name(col) }.join(", ") } )
328
328
  VALUES( DEFAULT #{ parent_columns.empty? ? '' : ' ,' + parent_columns.collect{ |col| "NEW.#{quote_column_name(col)}" }.join(", ") } ) ;
@@ -336,14 +336,14 @@ module ActiveRecord #:nodoc:
336
336
  # delete
337
337
  execute(<<~SQL)
338
338
  CREATE OR REPLACE RULE #{quote_column_name("#{child_view}_delete")} AS
339
- ON DELETE TO #{quote_column_name(child_view)} DO INSTEAD
339
+ ON DELETE TO #{quote_table_name(child_view)} DO INSTEAD
340
340
  DELETE FROM #{parent_table} WHERE #{parent_pk} = OLD.#{parent_pk}
341
341
  SQL
342
342
 
343
343
  # update
344
344
  execute(<<~SQL)
345
345
  CREATE OR REPLACE RULE #{quote_column_name("#{child_view}_update")} AS
346
- ON UPDATE TO #{quote_column_name(child_view)} DO INSTEAD (
346
+ ON UPDATE TO #{quote_table_name(child_view)} DO INSTEAD (
347
347
  #{ if parent_columns.empty?
348
348
  ''
349
349
  else
@@ -364,9 +364,9 @@ module ActiveRecord #:nodoc:
364
364
 
365
365
  def insert_returning_clause(parent_pk, child_pk, child_view)
366
366
  columns_cast_to_null = columns(child_view)
367
- .reject { |c| c.name == parent_pk}
368
- .map { |c| "CAST (NULL AS #{c.sql_type})" }
369
- .join(", ")
367
+ .reject { |c| c.name == parent_pk }
368
+ .map { |c| "CAST (NULL AS #{c.sql_type})" }
369
+ .join(", ")
370
370
  "RETURNING #{child_pk}, #{columns_cast_to_null}"
371
371
  end
372
372
 
@@ -1,3 +1,3 @@
1
1
  module UpdateableViewsInheritance
2
- VERSION = "1.4.4"
2
+ VERSION = "1.4.5"
3
3
  end
data/test/schema_test.rb CHANGED
@@ -184,22 +184,22 @@ class UpdateableViewsInheritanceSchemaTest < ActiveSupport::TestCase
184
184
  t.column :interrail_max_speed, :integer
185
185
  t.column :type, :string
186
186
  end
187
- create_child('interrail.steam_locomotives', :parent => 'interrail.locomotives') do |t|
188
- t.decimal :interrail_water_consumption, :precision => 6, :scale => 2
189
- t.decimal :interrail_coal_consumption, :precision => 6, :scale => 2
187
+ create_child('interrail.steam_locomotives', parent: 'interrail.locomotives') do |t|
188
+ t.decimal :interrail_water_consumption, precision: 6, scale: 2
189
+ t.decimal :interrail_coal_consumption, precision: 6, scale: 2
190
190
  end
191
191
  end
192
192
  end
193
193
 
194
194
  def test_create_child_in_schema
195
195
  CreateChildInSchema.up
196
- assert_equal %w(id
196
+ assert_equal %w[id
197
197
  interrail_coal_consumption
198
198
  interrail_max_speed
199
199
  interrail_name
200
200
  interrail_water_consumption
201
- type),
202
- @connection.columns('interrail.steam_locomotives').map{ |c| c.name }.sort
201
+ type],
202
+ @connection.columns('interrail.steam_locomotives').map(&:name).sort
203
203
  end
204
204
 
205
205
  class ChangeTablesInTwoInheritanceChains < ActiveRecord::Migration
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
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sava Chankov