activerecord_sqlserver_crm 5.1.2 → 5.1.3

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
  SHA1:
3
- metadata.gz: 14c8162bb4c63c744295b08a767f3dd347967557
4
- data.tar.gz: b0151c208209aad112ee07e250bbb63cf53c9339
3
+ metadata.gz: 883aa94a5b12bdc0d1af9c60f1a7c2a804556717
4
+ data.tar.gz: e86ab147af32ee872c652d59011eff0319911fe8
5
5
  SHA512:
6
- metadata.gz: 8778543933b59bc25e589cb93e12f85b64ba5ab93a3e2e7c715d209bbda04cf86835af423cd47746de8a9f5216bfae8cf5deba0367223f928638c30a28048d96
7
- data.tar.gz: 9032fb1c27e6ef1ddf1a400fe7cc3ea3ff448a6cb016202486d8ff72b4fb414ea4692ef716ccaf1cb82b5ecb98a4d179bdd4ffeeac7e5b8ec589ef730c4ab92f
6
+ metadata.gz: be3991ffe7c87808a3640011f81148ae63c74a7bb2d4513587f965421a4b20d5b89a4ad3aefb2b5da5f04c88c9306ef560a312a4562bac7169b89111da703580
7
+ data.tar.gz: 9824c7db65af61edd8fc6bf2198f189e135988b4141fc8b9ad59c5f20c8b2952a916d88921afc7dd63665697d16761ebf5d1870645bc19931913b8fe012ec1bf
@@ -41,7 +41,7 @@ module ActiveRecordExtension
41
41
  if has_errors
42
42
  raise_validation_error
43
43
  else
44
- reload unless id.nil?
44
+ reload_after_odata unless id.nil?
45
45
  end
46
46
  !has_errors
47
47
  end
@@ -53,11 +53,67 @@ module ActiveRecordExtension
53
53
  save
54
54
  end
55
55
 
56
+ # Created a method here because could not override ActiveRecord Persistance module because 3
57
+ # other modules override the reload method.
58
+ # I'm not really that thrilled with what I did here with this method for reload.
59
+ # Basically got parts from various ActiveRecord modules and combined them in here. I followed
60
+ # the reload through byebug to see how "reload" was being called
61
+ def reload_after_odata(options = nil)
62
+ # aggregations.rb
63
+ clear_aggregation_cache
64
+
65
+ # autosave_association.rb
66
+ @marked_for_destruction = false
67
+ @destroyed_by_association = nil
68
+
69
+ # associations.rb
70
+ clear_association_cache
71
+
72
+ # persistence.rb (only 1 line of code chaned in here)
73
+ self.class.connection.clear_query_cache
74
+
75
+ fresh_object =
76
+ if options && options[:lock]
77
+ self.class.unscoped { self.class.lock(options[:lock]).find(id) }
78
+ else
79
+ # Remove unscope here
80
+ self.class.find(id)
81
+ end
82
+
83
+ @attributes = fresh_object.instance_variable_get("@attributes")
84
+ @new_record = false
85
+
86
+ # attribute_methods/dirty.rb
87
+ @previous_mutation_tracker = nil
88
+ clear_mutation_trackers
89
+ @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
90
+
91
+ self
92
+ end
93
+
94
+
56
95
  def update_attribute(name, value)
57
96
  write_attribute(name,value)
58
97
  save
59
98
  end
60
99
 
100
+ # If using default_scope to restrict fields returned (with select)
101
+ # Change reload so it still uses the default scope rather than unscoped
102
+ def reload(options = nil)
103
+ self.class.connection.clear_query_cache
104
+
105
+ fresh_object =
106
+ if options && options[:lock]
107
+ self.class.unscoped { self.class.lock(options[:lock]).find(id) }
108
+ else
109
+ self.class.find(id)
110
+ end
111
+
112
+ @attributes = fresh_object.instance_variable_get("@attributes")
113
+ @new_record = false
114
+ self
115
+ end
116
+
61
117
  # add your static(class) methods here
62
118
  module ClassMethods
63
119
  def belongs_to_field?(field)
@@ -1,3 +1,3 @@
1
1
  module ActiverecordSqlserverCrm
2
- VERSION = "5.1.2"
2
+ VERSION = "5.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_sqlserver_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.2
4
+ version: 5.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rolf Lawrenz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails