chrono_model 0.12.3 → 0.13.0

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: 867208c8ba66191c8cf3bdebbc9eb4d811d59625
4
- data.tar.gz: 4651e58743b71d6cb54bba59929fec7c10ae80ac
3
+ metadata.gz: 883f6c37f76cc8b57b2d7f6b59e1a5627592907e
4
+ data.tar.gz: 8b35df17eb98dbddd3d0b5c5c046b7b9d7d00501
5
5
  SHA512:
6
- metadata.gz: 5dd88e44a1fedb1bb33199f2483c7d008fda05c753510d74b0fdb1fd9a2966138a0838b68d08d8e088d8e6bd36c50588f76357d327a966f6af68abc520ccbc6e
7
- data.tar.gz: 297be09d1673a4235bc3168fdfdf087612740790d33ca99b0eff033f24738536854ff7044f024a1b86df9da84c5fdb1e43cd9e90da2e212c2e02c5ce39bc475d
6
+ metadata.gz: 99fdb72cb9604d4566049199192b3982f5f44a088ad0f94335e677d8d847fd0a993390d6c17bb2381ec9c32c37c9fd378ba356ce7f9628b0e23aabe82b6702eb
7
+ data.tar.gz: 7e0be5293bcea607ee1fc1300ad28b491bc9620a2e4ee965f3763e7dadb509f702019fbbc27b254ba41243bd0e35ac4cf9131ab79beb561f87a814de2483b604
@@ -54,7 +54,7 @@ module ChronoModel
54
54
 
55
55
  extend TimeMachine::HistoryMethods
56
56
 
57
- scope :chronological, -> { order(:recorded_at, :hid) }
57
+ scope :chronological, -> { order('lower(validity)') }
58
58
 
59
59
  # The history id is `hid`, but this cannot set as primary key
60
60
  # or temporal assocations will break. Solutions are welcome.
@@ -105,6 +105,10 @@ module ChronoModel
105
105
  def save!(*)
106
106
  self.class.with_hid_pkey { super }
107
107
  end
108
+
109
+ def update_columns(*)
110
+ self.class.with_hid_pkey { super }
111
+ end
108
112
  end
109
113
 
110
114
  # Returns the previous history entry, or nil if this
@@ -137,13 +141,13 @@ module ChronoModel
137
141
  # Returns the first history entry
138
142
  #
139
143
  def first
140
- self.class.where(:id => rid).order('lower(validity)').first
144
+ self.class.where(:id => rid).chronological.first
141
145
  end
142
146
 
143
147
  # Returns the last history entry
144
148
  #
145
149
  def last
146
- self.class.where(:id => rid).order('lower(validity)').last
150
+ self.class.where(:id => rid).chronological.last
147
151
  end
148
152
 
149
153
  # Returns this history entry's current record
@@ -270,7 +274,7 @@ module ChronoModel
270
274
  history.order('upper(validity) DESC').offset(1).first
271
275
  else
272
276
  return nil unless (ts = pred_timestamp(options))
273
- self.class.as_of(ts).order(%[ #{options[:table] || self.class.quoted_table_name}."hid" DESC ]).find(options[:id] || id)
277
+ self.class.as_of(ts).order(%[ LOWER(#{options[:table] || self.class.quoted_table_name}."validity") DESC ]).find(options[:id] || id)
274
278
  end
275
279
  end
276
280
 
@@ -291,7 +295,7 @@ module ChronoModel
291
295
  def succ(options = {})
292
296
  unless self.class.timeline_associations.empty?
293
297
  return nil unless (ts = succ_timestamp(options))
294
- self.class.as_of(ts).order(%[ #{options[:table] || self.class.quoted_table_name}."hid" DESC ]).find(options[:id] || id)
298
+ self.class.as_of(ts).order(%[ LOWER(#{options[:table] || self.class.quoted_table_name}."validity"_ DESC ]).find(options[:id] || id)
295
299
  end
296
300
  end
297
301
 
@@ -1,3 +1,3 @@
1
1
  module ChronoModel
2
- VERSION = "0.12.3"
2
+ VERSION = "0.13.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrono_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcello Barnaba
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-07-11 00:00:00.000000000 Z
12
+ date: 2018-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord