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 +4 -4
- data/lib/chrono_model/time_machine.rb +9 -5
- data/lib/chrono_model/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 883f6c37f76cc8b57b2d7f6b59e1a5627592907e
|
4
|
+
data.tar.gz: 8b35df17eb98dbddd3d0b5c5c046b7b9d7d00501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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).
|
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).
|
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}."
|
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}."
|
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
|
|
data/lib/chrono_model/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|