sequel_bitemporal 0.8.8 → 0.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sequel/plugins/bitemporal.rb +13 -7
- data/sequel_bitemporal.gemspec +1 -1
- data/spec/bitemporal_date_spec.rb +27 -0
- 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: 68ac021c3521e98f78d3f9bc44c21267cc07c60a
|
4
|
+
data.tar.gz: fa89baf10e99cbed3ed83b2072a1c2e5b2a73ca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a5b6e13d4c74e905262dd6844db54b5550f8f626bfad46aff2093d82bc06217294f1cef60ca25361d6fd6604c48a1fdfb29531ea448a6de9f802075e6cfa1c
|
7
|
+
data.tar.gz: 132614240d0c4244938b136a7b5be58bd741368cd616c6fcd9335f4c4fc3156bd79fe1df1c4e4392a11988ca117ff690c5cde95c8e3e30fb7bb7f9ac46a97cbe
|
@@ -501,7 +501,8 @@ module Sequel
|
|
501
501
|
updated_by = (send(self.class.audit_updated_by_method) if audited?)
|
502
502
|
previous_values = @current_version_values || {}
|
503
503
|
current_version_values = {}
|
504
|
-
pending_version.columns
|
504
|
+
columns = pending_version.columns - excluded_columns_for_changes
|
505
|
+
columns.each do |column|
|
505
506
|
current_version_values[column] = pending_version.public_send(column)
|
506
507
|
end
|
507
508
|
|
@@ -588,9 +589,10 @@ module Sequel
|
|
588
589
|
return false unless @pending_version
|
589
590
|
return true unless current_version?
|
590
591
|
@current_version_values = current_version.values
|
591
|
-
pending_version.columns
|
592
|
-
|
593
|
-
|
592
|
+
columns = pending_version.columns - excluded_columns_for_changes
|
593
|
+
columns.detect do |column|
|
594
|
+
new_value = pending_version.send column
|
595
|
+
case column
|
594
596
|
when :id, :master_id, :created_at, :expired_at
|
595
597
|
false
|
596
598
|
when :valid_from
|
@@ -607,12 +609,12 @@ module Sequel
|
|
607
609
|
else
|
608
610
|
if model.version_uses_string_nilifier
|
609
611
|
if current_version.respond_to? :nil_string?
|
610
|
-
new_value = nil if current_version.nil_string?
|
611
|
-
elsif !model.version_class.skip_input_transformer?(:string_nilifier,
|
612
|
+
new_value = nil if current_version.nil_string? column, new_value
|
613
|
+
elsif !model.version_class.skip_input_transformer?(:string_nilifier, column)
|
612
614
|
new_value = model.version_class.input_transformers[:string_nilifier].call(new_value)
|
613
615
|
end
|
614
616
|
end
|
615
|
-
current_version.send(
|
617
|
+
current_version.send(column)!=new_value
|
616
618
|
end
|
617
619
|
end
|
618
620
|
end
|
@@ -621,6 +623,10 @@ module Sequel
|
|
621
623
|
self.class.excluded_columns
|
622
624
|
end
|
623
625
|
|
626
|
+
def excluded_columns_for_changes
|
627
|
+
[]
|
628
|
+
end
|
629
|
+
|
624
630
|
def initial_version
|
625
631
|
@initial_version ||= model.version_class.new
|
626
632
|
end
|
data/sequel_bitemporal.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "sequel_bitemporal"
|
6
|
-
s.version = "0.8.
|
6
|
+
s.version = "0.8.9"
|
7
7
|
s.authors = ["Joseph HALTER", "Jonathan TRON"]
|
8
8
|
s.email = ["joseph.halter@thetalentbox.com", "jonathan.tron@thetalentbox.com"]
|
9
9
|
s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
|
@@ -762,6 +762,33 @@ describe "Sequel::Plugins::Bitemporal" do
|
|
762
762
|
master = @master_class.with_current_version.all.first
|
763
763
|
expect( master.current_version.master.object_id ).not_to eq master.object_id
|
764
764
|
end
|
765
|
+
it "allow defining columns which must be ignored when checking for changes" do
|
766
|
+
closure = @version_class
|
767
|
+
with_excluded_columns = Class.new Sequel::Model do
|
768
|
+
set_dataset :rooms
|
769
|
+
plugin :bitemporal, version_class: closure
|
770
|
+
def excluded_columns_for_changes
|
771
|
+
[:name, :price]
|
772
|
+
end
|
773
|
+
end
|
774
|
+
master = with_excluded_columns.new
|
775
|
+
master.update_attributes name: "Single Standard", price: 98
|
776
|
+
expect(master).to have_versions %Q{
|
777
|
+
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
778
|
+
| Single Standard | 98 | 2009-11-28 | | 2009-11-28 | MAX DATE | true |
|
779
|
+
}
|
780
|
+
master.update_attributes name: "King Size", price: 94
|
781
|
+
expect(master).to have_versions %Q{
|
782
|
+
| name | price | created_at | expired_at | valid_from | valid_to | current |
|
783
|
+
| Single Standard | 98 | 2009-11-28 | | 2009-11-28 | MAX DATE | true |
|
784
|
+
}
|
785
|
+
master.update_attributes length: 1
|
786
|
+
expect(master).to have_versions %Q{
|
787
|
+
| name | price | length | created_at | expired_at | valid_from | valid_to | current |
|
788
|
+
| Single Standard | 98 | | 2009-11-28 | 2009-11-28 | 2009-11-28 | MAX DATE | |
|
789
|
+
| King Size | 94 | 1 | 2009-11-28 | | 2009-11-28 | MAX DATE | true |
|
790
|
+
}
|
791
|
+
end
|
765
792
|
end
|
766
793
|
|
767
794
|
describe "Sequel::Plugins::Bitemporal", "with audit" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_bitemporal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph HALTER
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|