torque-postgresql 2.0.4 → 2.0.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: f108bfb672743d7edd701b77eb102aa6f9164b4981e1f366d2354d9e8cf3360b
4
- data.tar.gz: 60d7208f0798acbde69aee78fca7a92d4824c75dcecc44acd16dcf59568f0e04
3
+ metadata.gz: fe8259f8bb0f4c8c67c32919ec2bc2ca448c5372857670ed5fbd4d932e3160d6
4
+ data.tar.gz: 3786a17977e0d4ffd81c1521c9e469fd411b6d15b413866941adc911beb8c2dd
5
5
  SHA512:
6
- metadata.gz: 0a463f94c5a09f74bbb2ba57fe9fb2f7fe649f243c239f7709180c29988f2b5424bffec68d0ec1d2c4ae8ad1191d6156e96dd00c2a66a2a473e02411c563e21f
7
- data.tar.gz: 1568915cd13e2b93b77a702cfd346326aa9e07605aac3deca0f3dacbe82b24762a84f3007a4dffc493888c94802724defbfc01037d0bad984e3735783a790f35
6
+ metadata.gz: f35b0eb94b260cc5c5c9d08a47dcba841d9044c9acc52d30b0ad13b1e0a6ecbe2ef10ca940828870fbf5f04b387827b9c56db43523e0585f77f950a72e368b51
7
+ data.tar.gz: a3b899a4c7a26f9ff9a6a9af7f0d41a6ed193e96a76d96ae17a2423eb0b4bc6ea59138684cd324a28ccfad7374528c1cb72d4ae89a0ad710ce66655d3e355e50
@@ -18,7 +18,6 @@ require 'torque/postgresql/arel'
18
18
  require 'torque/postgresql/adapter'
19
19
  require 'torque/postgresql/associations'
20
20
  require 'torque/postgresql/attributes'
21
- require 'torque/postgresql/autosave_association'
22
21
  require 'torque/postgresql/auxiliary_statement'
23
22
  require 'torque/postgresql/base'
24
23
  require 'torque/postgresql/inheritance'
@@ -13,6 +13,10 @@ module Torque
13
13
  @inversed = self.target.present?
14
14
  end
15
15
 
16
+ def skip_statement_cache?(*)
17
+ super || reflection.connected_through_array?
18
+ end
19
+
16
20
  private
17
21
 
18
22
  def set_owner_attributes(record)
@@ -35,6 +35,7 @@ module Torque
35
35
  ids.each { |id| records[id].concat(Array.wrap(record)) }
36
36
  end
37
37
 
38
+ records.default_proc = nil
38
39
  owners.each do |owner|
39
40
  associate_records_to_owner(owner, records[owner[owner_key_name]] || [])
40
41
  end
@@ -9,7 +9,7 @@ module Torque
9
9
  module Builder
10
10
  def self.include_on(klass, method_name, builder_klass, **extra, &block)
11
11
  klass.define_singleton_method(method_name) do |*args, **options|
12
- return unless connection.table_exists?(table_name)
12
+ return unless table_exists?
13
13
 
14
14
  args.each do |attribute|
15
15
  begin
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Torque
4
4
  module PostgreSQL
5
- VERSION = '2.0.4'
5
+ VERSION = '2.0.5'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torque-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-13 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -211,7 +211,6 @@ files:
211
211
  - lib/torque/postgresql/attributes/enum_set.rb
212
212
  - lib/torque/postgresql/attributes/lazy.rb
213
213
  - lib/torque/postgresql/attributes/period.rb
214
- - lib/torque/postgresql/autosave_association.rb
215
214
  - lib/torque/postgresql/auxiliary_statement.rb
216
215
  - lib/torque/postgresql/auxiliary_statement/settings.rb
217
216
  - lib/torque/postgresql/base.rb
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Torque
4
- module PostgreSQL
5
- module AutosaveAssociation
6
- module ClassMethods
7
- def add_autosave_association_callbacks(reflection)
8
- return super unless reflection.macro.eql?(:belongs_to_many)
9
-
10
- save_method = :"autosave_associated_records_for_#{reflection.name}"
11
- define_non_cyclic_method(save_method) { save_belongs_to_many_array(reflection) }
12
-
13
- if PostgreSQL::AR610
14
- around_save(:around_save_collection_association)
15
- else
16
- before_save(:before_save_collection_association)
17
- after_save(:after_save_collection_association) if ::ActiveRecord::Base
18
- .instance_methods.include?(:after_save_collection_association)
19
- end
20
-
21
- before_create(save_method)
22
- before_update(save_method)
23
-
24
- define_autosave_validation_callbacks(reflection)
25
- end
26
- end
27
-
28
- def save_belongs_to_many_array(reflection)
29
- save_collection_association(reflection)
30
-
31
- association = association_instance_get(reflection.name)
32
- return unless association
33
-
34
- klass_attr = reflection.active_record_primary_key
35
- source_attr = reflection.foreign_key
36
-
37
- records = association.target.each_with_object(klass_attr)
38
- write_attribute(source_attr, records.map(&:read_attribute).compact)
39
- end
40
- end
41
-
42
- ::ActiveRecord::Base.singleton_class.prepend(AutosaveAssociation::ClassMethods)
43
- ::ActiveRecord::Base.include(AutosaveAssociation)
44
- end
45
- end