Skip to content

Commit

Permalink
Prevent delegation of columns which are both in master and version
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephHalter committed Aug 7, 2014
1 parent 50b11f3 commit 824365c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/sequel/plugins/bitemporal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def self.configure(master, opts = {})
@propagate_per_column = opts.fetch(:propagate_per_column, false)
@version_uses_string_nilifier = version.plugins.map(&:to_s).include? "Sequel::Plugins::StringNilifier"
@excluded_columns = Sequel::Plugins::Bitemporal.bitemporal_excluded_columns
@excluded_columns += columns
@excluded_columns += Array opts[:excluded_columns] if opts[:excluded_columns]
@use_ranges = if opts[:ranges]
db = self.db
Expand Down
16 changes: 16 additions & 0 deletions spec/bitemporal_date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,22 @@
expect{ master.name }.to raise_error NoMethodError
master.price.should == 98
end
it "avoids delegation of columns which are both in master and version" do
closure = @version_class
DB.create_table! :rooms_with_name do
primary_key :id
String :name
end
without_delegation_class = Class.new Sequel::Model do
set_dataset :rooms_with_name
plugin :bitemporal, version_class: closure
end
master = without_delegation_class.new name: "Master Hotel"
master.attributes = {name: "Single Standard", price: 98}
master.name.should == "Master Hotel"
master.price.should == 98
DB.drop_table :rooms_with_name
end
it "get current_version association name from class name" do
class MyNameVersion < Sequel::Model
set_dataset :room_versions
Expand Down

0 comments on commit 824365c

Please sign in to comment.