1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
|
= Deprecated Features
* Dataset mutation is now deprecated. Users should switch to using
the non-mutating methods.
# Instead of:
dataset.where!(:foo)
# Switch to:
dataset = dataset.where(:foo)
* Support for the Cubrid, Firebird, Informix, and Progress databases
has been deprecated. Any users of this support should consider
creating an external adapter with the current code and maintaining
such support themselves.
* The do (DataObjects), swift, and jdbc/as400 adapters have been
deprecated. Any users of these adapters should consider creating an
external adapter with the current code and maintaining the adapter
themselves.
* Model transaction hooks (after_commit, after_rollback,
after_destroy_commit, after_destroy_rollback) are now deprecated.
Users should switch to calling the after_commit and after_rollback
database transaction hooks directly.
# Instead of:
def after_commit
super
do_something
end
# Switch to:
def after_save
super
db.after_commit{do_something}
end
* Passing a block to Database#from is now deprecated. For backwards
compatibility, this block affected the WHERE clause instead of the
FROM clause. In Sequel 5, Database#from blocks will be treated like
Dataset#from blocks, and will affect the FROM clause. This behavior
has been available for years by using the from_block extension.
# Instead of:
DB.from(:foo){a > b}
# Switch to:
DB.from(:foo).where{a > b}
* Passing non-hash arguments and multiple arguments to the
model association methods is now deprecated. Switch to using a
hash as an argument.
# Instead of:
model.association(true)
model.association(proc{|ds| ds.where(:foo)})
# Switch to:
model.association(:reload=>true)
model.association(:callback=>proc{|ds| ds.where(:foo)})
model.association{|ds| ds.where(:foo)}
* Passing procs as filter arguments is now deprecated. These should
now be passed as blocks instead of arguments.
# Instead of:
dataset.where(proc{foo > bar})
# Switch to:
dataset.where{foo > bar}
* Passing multiple arguments or an array as filter arguments when the
array/arguments does not represent a conditions specifier (array of
two element arrays, treated like a hash) is now deprecated. Switch
to calling the filter method separately with each argument or using
Sequel.& to combine the arguments:
# Instead of:
dataset.where(:foo, :bar)
dataset.where([:foo, :bar])
# Switch to:
dataset.where(:foo).where(:bar)
dataset.where(Sequel.&(:foo, :bar))
* Returning false from model before hooks to cancel an action is
now deprecated. Switch to calling cancel_action instead.
# Instead of:
def before_save
return false if something
super
end
# Switch to:
def before_save
cancel_action('something bad') if something
super
end
* Database#each_server has been deprecated. Switch to using
Database#servers and Database#with_server from server_block
extension:
# Instead of:
DB.each_server{|db| db.run("foo")}
# Switch to:
DB.extension :server_block
DB.servers.each{|s| DB.with_server(s){DB.run("foo")}}
* Calling Database#add_servers and Database#remove_servers on a
database that does not use the :servers option is now deprecated.
Currently, the calls to add_servers and remove_servers are
ignored for such databases, which can hide errors.
* Sequel::Postgres::PG_NAMED_TYPES is now deprecated. Switch to
calling Database#add_named_conversion_proc instead.
# Instead of:
require 'sequel/adapters/utils/pg_types'
Sequel::Postgres::PG_NAMED_TYPES[:foo] = lambda{|v| v}
DB = Sequel.connect('postgres://...')
# Switch to:
DB = Sequel.connect('postgres://...')
DB.add_named_conversion_proc(:foo){|v| v}
* Modifying the identifier mangling settings for a Database or
Dataset is now deprecated unless the identifier_mangling extension
is explicitly loaded into the Database instance.
* The Sequel::Database.single_threaded accessor is now deprecated.
Switch to using Sequel.single_threaded= and Sequel.single_threaded?.
* Sequel::Database.identifier_input_method,
Sequel::Database.identifier_output_method,
and Sequel::Database.quote_identifier accessors are now deprecated.
Switch to modifying the setting for each Database instance.
* Sequel.identifier_input_method=, Sequel.identifier_output_method=,
and Sequel.quote_identifer= setter methods are now deprecated.
Switch to modifying the setting for each Database instance.
* Calling Dataset#delete/update/truncate on datasets with limits
or offsets is now deprecated, unless the database will respect
the limit or offset. Currently, only MySQL and Microsoft SQL
Server have limited support for such deletes and updates. You
should either call unlimited or skip_limit_check before calling
delete/update/truncate.
* Deprecate having duplicate column names in subclass tables when
using the class_table_inheritance plugin. The documentation has
warned against this for a long time, but the code did not enforce
it.
* When using the association_pks plugin setter methods without the
:delay_pks association option set, a warning is now issued. In
Sequel 5, the default will be to assume that the :delay_pks
option is :always, and not to make modifications until the object
is saved. If you would like to keep the current behavior, set
the :delay_pks=>false association option.
The current :delay_pks=>true behavior will be removed in Sequel 5,
with it being treated like :delay_pks=>:always. If you are relying
on the current behavior of :delay_pks=>true (delay for new objects,
immediate for existing objects), you will need to update your code.
* Database#dup/clone are now deprecated. They have never been
handled correctly, since the default implementation from Kernel
has been used.
* Model.dup/clone are now deprecated. They have never been
handled correctly, as the default implemenation from Kernel/Module
has been used.
* Database#use on MySQL is now deprecated. Switch to creating a new
Database instance instead of modifying the database for an existing
instance.
* Database#database_name on MySQL is now deprecated. Switch to asking
the database server which database you are connected to:
# Instead of:
DB.database_name
# Switch to:
DB.get{DATABASE{}}
* In the lazy_attributes, nested_attributes, composition, and
serialization plugins, the *_module accessors are now deprecated.
These were implementation details that should not have been
exposed.
* The schema plugin is now deprecated. Switch to defining the schema
before creating the model class using the Database schema methods.
* The scissors plugin is deprecated. It existed for compatibility
with Sequel 3, but it is dangerous as it makes it easier to modify
all rows when the intent was to modify a single row.
* The prepared_statements_associations and prepared_statements_with_pk
plugins are now deprecated. These plugins generally make things
slower.
* Dataset#unbind, Sequel::Unbinder, and Sequel::UnbindDuplicate are
now deprecated. This mostly existed to support the
prepared_statements_associations and prepared_statements_with_pk
plugins.
* Sequel::Error::* exception class aliases are now deprecated. Switch
to using the exception classes in the Sequel namespace.
* Sequel::BeforeHookFailed is now deprecated. Switch to using
Sequel::HookFailed.
* Calling Sequel::Qualifier.new with 2 arguments is now deprecated.
Users should switch to calling it with a single argument (the
table used for qualifying unqualified identifiers).
* Treating unrecognized prepared statement types as :select is now
deprecated. Switch to using :select as the prepared statement
type.
* The @was_new instance variable available in model after_save hooks
is now deprecated. There is no deprecation warning associated
with this change.
# Instead of:
def after_save
super
if @was_new
do_something
else
do_something_else
end
end
# Switch to:
def after_create
super
do_something
end
def after_update
super
do_something_else
end
* The @columns_updated instance variable available in model
after_save and after_update hooks is deprecated. Switch to
using the new columns_updated plugin and calling the
columns_updated method.
* The Sequel.cache_anonymous_models accessor has been deprecated.
Switch to using Sequel::Model.cache_anonymous_models.
* Sequel::Model::ANONYMOUS_MODEL_CLASSES and
Sequel::Model::ANONYMOUS_MODEL_CLASSES_MUTEX have been
deprecated.
* Sequel::Database::ResetIdentifierMangling has been deprecated.
= New Features
* A validation_contexts plugin has been added, which adds support
for a :validation_context option to Model#save and Model#valid?.
The value for this option will be available via the
validation_context method inside the validation hooks and
validate method.
class Album < Sequel::Model
plugin :validation_contexts
def validate
super
if validation_context == :approve
errors.add(:status_id, 'not 42') unless status_id == 42
end
end
end
album = Album.first
album.status_id = 41
album.valid?(:validation_context=>:approve) # => false
album.status_id = 42
album.valid?(:validation_context=>:approve) # => true
* A columns_updated plugin has been added, allowing you to get
access to the hash used for updating a model instance via the
columns_updated method:
class Album < Sequel::Model
plugin :columns_updated
def after_update
super
if columns_updated.has_key?(:foo)
do_something(columns_updated[:foo])
end
end
end
* Dataset#delete on Microsoft SQL Server now respects limits. Note
that Microsoft SQL Server does not respect orders for deletes, only
limits, which makes this support not very useful. Currently a
deprecation warning will be issued when using a delete with an
order and a limit, and in Sequel 5 an exception will be raised.
* An odbc/oracle subadapter has been added.
* A Model.dataset_module_class accessor has been added, allowing
plugins to add support for custom behavior in dataset_module blocks.
* Support for deprecating constants on Ruby 2.3+ has been added.
Note that you will only get warnings for deprecated constant
use if you are running on Ruby 2.3+. If you are running on a
previous version of Ruby, you should scan your code manually for
deprecated constant use.
= Other Improvements
* Using Model#cancel_action inside validation hooks now works
correctly when Model#valid? is called.
* Model#[] now handles columns with false values correctly when using
the split_values plugin.
* When calling Dataset#union/intersect/except on a dataset with
an offset but no limit, the dataset is wrapped in a subquery, just
like a dataset with a limit.
* The dumping of 64-bit autoincrementing primary key columns by the
schema_dumper extension is now handled correctly when using the
:same_db option.
* The schema_dumper extension now supports the :schema option when
dumping schema.
* On Microsoft SQL Server and SQLAnywhere, ORDER BY clauses now come
after UNION/INTERSECT/EXCEPT instead of before, fixing issues when
the :from_self=>false option is used with union/intersect/except
and an order is applied afterward.
* On Microsoft SQL Server, if calling Dataset#union/intersect/except
on a dataset with an order and without a limit or offset, the order
is removed. When using UNION/INTERSECT/EXCEPT, Microsoft SQL
Server does not guarantee any ordering unless you specify an order
for the compound dataset. As a general rule, you should always
apply orders after compounds instead of before.
* On Microsoft SQL Server <2012, when using a dataset with an offset
without a limit in a UNION/INTERSECT/EXCEPT query, Sequel now uses
TOP (100) PERCENT to work around the limitation that using orders
in subqueries is not supported unless there is a limit (offsets
are emulated by a ROW_NUMBER window function with an order in this
case).
* Database#indexes on MySQL now handles qualified identifiers.
* Sequel now literalizes Sequel::SQLTime instances with 3 fractional
digits in the jdbc/postgresql adapter, fixing issues on JRuby
9.1.8.0+ (the first JRuby version to support greater than
millisecond precision).
= Backwards Compatibility
* When using the association_proxies plugin and passing a block when
loading the plugin, the :proxy_argument option in hash passed to
the block is now an empty hash instead of nil if no argument was
given to the association method.
* The private Model#_valid? method now takes a single options hash
argument, instead of 2 arguments.
* The pg_hstore extension no longer modifies PG_NAMED_TYPES. This
should not affect behavior if the pg_hstore extension is loaded
into the Database instance.
* Support for pg <0.8.0 has been dropped. pg 0.8.0 was released in
January 2008.
|