New Features¶ ↑
-
A duplicate_columns_handler extension has been added, for printing a warning or raising an exception if a dataset returns multiple columns with the same name. You can set this globally for the Database:
DB.extension :duplicate_columns_handler DB.opts[:on_duplicate_columns] = :warn DB.opts[:on_duplicate_columns] = proc do |columns| columns.include?(:foo) ? :raise : :ignore end
or for specific datasets:
ds = DB[:table].extension(:duplicate_columns_handler) ds = ds.on_duplicate_columns(:raise) ds = ds.on_duplicate_columns do |columns| columns.include?(:foo) ? :raise : :ignore end
This makes it easier to detect when duplicate columns are returned, which in some cases can cause undesired behavior, such as the values for later columns of the same name overwriting values for earlier columns.
-
The Dataset#to_hash, to_hash_groups, select_hash, and select_hash_groups methods now take an options hash as a third argument. This options hash can now contain a :hash option, which specifies the object in which the resulting values should be placed. You can use this to have the values inserted into a custom hash, or another object responding to [] and []=.
-
A validators_operator validation has been added to the validation_helpers plugin:
class Example < Sequel::Model def validate super validates_operator(:>, 3, :column1) validates_operator(:<=, 4, [:column2, :column3]) end end
-
The pg_range extension now adds a register_range_type Database method, supporting per-Database custom range types:
DB.register_range_type('timerange')
-
The dataset_associations plugin now supports a :dataset_associations_join association option on associations that use joined datasets. This option will have the datasets returned by the dataset association methods join to the same tables that would be joined when retriving the associated objects, allowing selected columns, orders, and filters that reference columns in the joined tables to work correctly.
-
The Database :preconnect option can now be set to :concurrently, which will create the connections in separate threads. This can significantly speed up preconnection in high-latency environments.
-
The Database :name option is now supported, holding an arbitrary name for the database. Currently, it is only used in PoolTimeout exception messages, but it may be used in other places in the future.
Other Improvements¶ ↑
-
The prepared_statements_safe plugin now works correctly when using CURRENT_DATE and CURRENT_TIMESTAMP default values for columns.
-
Sequel
now recognizes an addition unique constraint violation on Microsoft SQL Server. -
PoolTimeout exception messages now include the server/shard to which the connection was attempted when using the sharded threaded connection pool.