spec/deprecated_relations_spec.rb in sequel-1.4.0 vs spec/deprecated_relations_spec.rb in sequel-1.5.0
- old
+ new
@@ -7,11 +7,11 @@
@c1 = Class.new(Sequel::Model(:attributes)) do
end
@c2 = Class.new(Sequel::Model(:nodes)) do
- def columns; [:id, :parent_id]; end
+ columns :id, :parent_id, :blah
end
@dataset = @c2.dataset
@dataset.extend(Module.new {
@@ -42,32 +42,10 @@
p.values.should == {:hey => 1}
MODEL_DB.sqls.should == ["SELECT * FROM nodes WHERE (id = 567) LIMIT 1"]
end
- # the new implementation doesn't support plain datasets as associations
- # it "should support plain dataset in the from option" do
- # @c2.one_to_one :parent, :from => MODEL_DB[:xyz]
- #
- # d = @c2.new(:id => 1, :parent_id => 789)
- # p = d.parent
- # p.class.should == Hash
- #
- # MODEL_DB.sqls.should == ["SELECT * FROM xyz WHERE (id = 789) LIMIT 1"]
- # end
-
- # the new implementation doesn't support plain datasets as associations
- # it "should support table name in the from option" do
- # @c2.one_to_one :parent, :from => :abc
- #
- # d = @c2.new(:id => 1, :parent_id => 789)
- # p = d.parent
- # p.class.should == Hash
- #
- # MODEL_DB.sqls.should == ["SELECT * FROM abc WHERE (id = 789) LIMIT 1"]
- # end
-
it "should return nil if key value is nil" do
@c2.one_to_one :parent, :from => @c2
d = @c2.new(:id => 1)
d.parent.should == nil
@@ -102,10 +80,11 @@
@c1 = Class.new(Sequel::Model(:attributes)) do
end
@c2 = Class.new(Sequel::Model(:nodes)) do
+ columns :id
end
end
it "should define a getter method" do
@c2.one_to_many :attributes, :from => @c1, :key => :node_id
@@ -114,35 +93,16 @@
a = n.attributes_dataset
a.should be_a_kind_of(Sequel::Dataset)
a.sql.should == 'SELECT * FROM attributes WHERE (node_id = 1234)'
end
- # the new implementation doesn't support plain datasets as associations
- # it "should support plain dataset in the from option" do
- # @c2.one_to_many :attributes, :from => MODEL_DB[:xyz], :key => :node_id
- #
- # n = @c2.new(:id => 1234)
- # a = n.attributes
- # a.should be_a_kind_of(Sequel::Dataset)
- # a.sql.should == 'SELECT * FROM xyz WHERE (node_id = 1234)'
- # end
-
- # the new implementation doesn't support plain datasets as associations
- # it "should support table name in the from option" do
- # @c2.one_to_many :attributes, :from => :abc, :key => :node_id
- #
- # n = @c2.new(:id => 1234)
- # a = n.attributes
- # a.should be_a_kind_of(Sequel::Dataset)
- # a.sql.should == 'SELECT * FROM abc WHERE (node_id = 1234)'
- # end
-
it "should support implicit key names" do
$c1 = @c1
module Music
class BlueNote < Sequel::Model
one_to_many :attributes, :from => $c1
+ columns :id
end
end
n = Music::BlueNote.new(:id => 1234)
a = n.attributes_dataset