Path: | doc/release_notes/1.1.txt |
Last Update: | Wed Apr 17 08:46:45 +0000 2013 |
With the new Sequel release you no longer need to explicitly specify the table name for each model class, assuming your model name is the singular of the table name (just like in ActiveRecord or DataMapper):
class UglyBug < Sequel::Model end UglyBug.table_name #=> :ugly_bugs
Sequel model now include validation functionality which largly follows the validations offered in ActiveRecord. Validations can be checked anytime by calling Model#valid?, with validation errors accessible through Model#errors:
class Item < Sequel::Model validates_presence_of :name end my_item = Item.new my_item.valid? #=> false my_item.errors.full_messages #=> ["name is not present"]
The Model#save method has been changed to check for validity before saving. If the model instance is not valid, the save method returns false without saving the instance. You can also bypass the validity test by calling Model#save! instead.
Model classes also now support virtual attributes, letting you assign values to any attribute (virtual or persistent) at initialization time:
class User < Sequel::Model attr_accessor :password end u = User.new(:password => 'blah', ...) u.password #=> 'blah'
Also, virtual attributes can be validated just like persistent attributes.
attributes and auto-filtering of unrelated parameters, and changed Model.create_with_params to support virtual attributes (128).
naming or inheriting the superclass dataset (thanks celldee).
(135).
also fixes problem with validating objects initialized with string keys (136).
can now accept options loaded from YAML files. Database.connect also automatically converts :username option into :user for compatibility with existing YAML configuration files for AR and DataMapper.
database name, also added support for untitled columns in ODBC::Dataset (thanks Leonid Borisenko).
(123).
and put HAVING clause before ORDER BY clause (133).
specified (114).
for mysql date types (thanks drfreeze).
if not defined (for pure-ruby postgres driver).
quotes.
transactions, table_exists?, tables and additional specs (thanks Liming Lian 122).
e.g. using Database#fetch.
from the original dataset.