IMO, unless overriden by set_primary_key, the order of symbols in the array
returned by Sequel::Model.primary_key should match the actual order of the
primary key:
describe "Sequel::Model.primary_key" do
before do
class ::Item < Sequel::Model
plugin :schema
create_table do
Integer :a
Integer :b
primary_key [:b, :a]
end
end
end
after do
@db.drop_table(:items)
Object.send(:remove_const, :Item)
end
specify "should return columns in the correct order" do
Item.primary_key.should == [:b, :a]
end
end
This spec will currently fail:
expected: [:b, :a],
got: [:a, :b] (using ==)
This can make an important difference if you are using Model.primary_key to
enforce ordering by the primary key columns. Ordering by (b, a) exploits the
order of the primary key index. Ordering by (a, b) typically introduces a
sort.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.