Path: | doc/release_notes/4.44.0.txt |
Last Update: | Fri Oct 06 03:25:22 +0000 2017 |
One advantage of using this is it will raise an exception if it recognizes that any of your associations are not defined correctly, such as referencing an associated class that doesn‘t exist.
Sequel::Model.plugin :subclasses Dir['./models/*.rb'].each{|f| require f} Sequel::Model.freeze_descendents
DB['SELECT * FROM foo'].where(:bar=>1) # SELECT * FROM foo DB.extension :implicit_subquery DB['SELECT * FROM foo'].where(:bar=>1) # SELECT * FROM (SELECT * FROM foo) AS t1 WHERE (bar = 1)
class Album < Sequel::Model; end Album.where_all(:id=>[1,2,3]) # => [Album[1], Album[3], Album[2]] Album.where_each(:id=>[1,2,3]) do |album| # ... end Album.select(:name).where_single_value(:id=>1) # "Album's Name"
These methods are designed for use by other dataset methods you define, and are optimized for frozen datasets if the methods will be called multiple times on the same dataset. where_all and where_each can increase performance by up to 40% for small datasets compared to where.all and where.each. where_single_value can be up to twice as fast as where.single_value.
class Album < Sequel::Model many_to_one :artist dataset_module do eager :with_artist, :artist end end Album.with_artist.all # eagerly loads artist association
Sequel::SQL::Blob.new('a') # => #<Sequel::SQL::Blob:0xa6f3a3c3710 bytes=1 content="a"> Sequel::SQLTime.now # => #<Sequel::SQLTime 10:03:06> Sequel::LiteralString.new("foo") # => #<Sequel::LiteralString "foo"> class Album < Sequel::Model; end Album.many_to_one :artist # => #<Sequel::Model::Associations::ManyToOneAssociationReflection Album.many_to_one :artist> Sequel::SQL::ValueList.new([[1,2]]) # => #<Sequel::SQL::ValueList [[1, 2]]>