File: 3.11.0.txt [sequel-3.12.0 Documentation]

### Home Classes Methods

### Files

- CHANGELOG
- COPYING
- README.rdoc
- advanced_associations.rdoc
- association_basics.rdoc
- cheat_sheet.rdoc
- dataset_basics.rdoc
- dataset_filtering.rdoc
- migration.rdoc
- model_hooks.rdoc
- opening_databases.rdoc
- prepared_statements.rdoc
- querying.rdoc
- reflection.rdoc
- 1.0.txt
- 1.1.txt
- 1.3.txt
- 1.4.0.txt
- 1.5.0.txt
- 2.0.0.txt
- 2.1.0.txt
- 2.10.0.txt
- 2.11.0.txt
- 2.12.0.txt
- 2.2.0.txt
- 2.3.0.txt
- 2.4.0.txt
- 2.5.0.txt
- 2.6.0.txt
- 2.7.0.txt
- 2.8.0.txt
- 2.9.0.txt
- 3.0.0.txt
- 3.1.0.txt
- 3.10.0.txt
- 3.11.0.txt
- 3.12.0.txt
- 3.2.0.txt
- 3.3.0.txt
- 3.4.0.txt
- 3.5.0.txt
- 3.6.0.txt
- 3.7.0.txt
- 3.8.0.txt
- 3.9.0.txt
- sharding.rdoc
- sql.rdoc
- virtual_rows.rdoc

### Class Index

Quicksearch

- Sequel
- Sequel::ADO
- Sequel::ADO::Database
- Sequel::ADO::Dataset
- Sequel::ADO::MSSQL
- Sequel::ADO::MSSQL::DatabaseMethods
- Sequel::ADO::MSSQL::Dataset
- Sequel::AdapterNotFound
- Sequel::Amalgalite
- Sequel::Amalgalite::Database
- Sequel::Amalgalite::Dataset
- Sequel::Amalgalite::SequelTypeMap
- Sequel::BasicObject
- Sequel::BeforeHookFailed
- Sequel::ConnectionPool
- Sequel::ConnectionPool::ClassMethods
- Sequel::DB2
- Sequel::DB2::Database
- Sequel::DB2::Dataset
- Sequel::DBI
- Sequel::DBI::Database
- Sequel::DBI::Dataset
- Sequel::DataObjects
- Sequel::DataObjects::Database
- Sequel::DataObjects::Dataset
- Sequel::DataObjects::MySQL
- Sequel::DataObjects::MySQL::DatabaseMethods
- Sequel::DataObjects::MySQL::Dataset
- Sequel::DataObjects::Postgres
- Sequel::DataObjects::Postgres::AdapterMethods
- Sequel::DataObjects::Postgres::DatabaseMethods
- Sequel::DataObjects::Postgres::Dataset
- Sequel::DataObjects::SQLite
- Sequel::DataObjects::SQLite::DatabaseMethods
- Sequel::DataObjects::SQLite::Dataset
- Sequel::Database
- Sequel::DatabaseConnectionError
- Sequel::DatabaseDisconnectError
- Sequel::DatabaseError
- Sequel::Dataset
- Sequel::Dataset::ArgumentMapper
- Sequel::Dataset::Pagination
- Sequel::Dataset::PreparedStatementMethods
- Sequel::Dataset::QueryBlockCopy
- Sequel::Dataset::StoredProcedureMethods
- Sequel::Dataset::StoredProcedures
- Sequel::Dataset::UnnumberedArgumentMapper
- Sequel::Error
- Sequel::Error::AdapterNotFound
- Sequel::Error::InvalidOperation
- Sequel::Error::InvalidValue
- Sequel::Error::PoolTimeoutError
- Sequel::Error::Rollback
- Sequel::Firebird
- Sequel::Firebird::Database
- Sequel::Firebird::Dataset
- Sequel::Inflections
- Sequel::Informix
- Sequel::Informix::Database
- Sequel::Informix::Dataset
- Sequel::IntegerMigrator
- Sequel::InvalidOperation
- Sequel::InvalidValue
- Sequel::JDBC
- Sequel::JDBC::AS400
- Sequel::JDBC::AS400::DatabaseMethods
- Sequel::JDBC::AS400::Dataset
- Sequel::JDBC::Database
- Sequel::JDBC::Dataset
- Sequel::JDBC::Dataset::PreparedStatementMethods
- Sequel::JDBC::Dataset::StoredProcedureMethods
- Sequel::JDBC::H2
- Sequel::JDBC::H2::DatabaseMethods
- Sequel::JDBC::H2::Dataset
- Sequel::JDBC::JavaLang
- Sequel::JDBC::JavaSQL
- Sequel::JDBC::JavaxNaming
- Sequel::JDBC::MSSQL
- Sequel::JDBC::MSSQL::DatabaseMethods
- Sequel::JDBC::MSSQL::Dataset
- Sequel::JDBC::MySQL
- Sequel::JDBC::MySQL::DatabaseMethods
- Sequel::JDBC::MySQL::Dataset
- Sequel::JDBC::Oracle
- Sequel::JDBC::Oracle::DatabaseMethods
- Sequel::JDBC::Oracle::Dataset
- Sequel::JDBC::Postgres
- Sequel::JDBC::Postgres::AdapterMethods
- Sequel::JDBC::Postgres::DatabaseMethods
- Sequel::JDBC::Postgres::Dataset
- Sequel::JDBC::SQLite
- Sequel::JDBC::SQLite::DatabaseMethods
- Sequel::JDBC::SQLite::Dataset
- Sequel::LiteralString
- Sequel::LooserTypecasting
- Sequel::MSSQL
- Sequel::MSSQL::DatabaseMethods
- Sequel::MSSQL::DatasetMethods
- Sequel::Metaprogramming
- Sequel::Migration
- Sequel::MigrationDSL
- Sequel::Migrator
- Sequel::Migrator::Error
- Sequel::Model
- Sequel::Model::Associations
- Sequel::Model::Associations::AssociationDatasetMethods
- Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ClassMethods
- Sequel::Model::Associations::DatasetMethods
- Sequel::Model::Associations::InstanceMethods
- Sequel::Model::Associations::ManyToManyAssociationReflection
- Sequel::Model::Associations::ManyToOneAssociationReflection
- Sequel::Model::Associations::OneToManyAssociationReflection
- Sequel::Model::Associations::OneToOneAssociationReflection
- Sequel::Model::ClassMethods
- Sequel::Model::DatasetMethods
- Sequel::Model::Errors
- Sequel::Model::InstanceMethods
- Sequel::MySQL
- Sequel::MySQL::Database
- Sequel::MySQL::DatabaseMethods
- Sequel::MySQL::Dataset
- Sequel::MySQL::Dataset::CallableStatementMethods
- Sequel::MySQL::Dataset::PreparedStatementMethods
- Sequel::MySQL::Dataset::StoredProcedureMethods
- Sequel::MySQL::DatasetMethods
- Sequel::NamedTimezones
- Sequel::NoExistingObject
- Sequel::NotImplemented
- Sequel::ODBC
- Sequel::ODBC::Database
- Sequel::ODBC::Dataset
- Sequel::ODBC::MSSQL
- Sequel::ODBC::MSSQL::DatabaseMethods
- Sequel::ODBC::MSSQL::Dataset
- Sequel::OpenBase
- Sequel::OpenBase::Database
- Sequel::OpenBase::Dataset
- Sequel::Oracle
- Sequel::Oracle::Database
- Sequel::Oracle::DatabaseMethods
- Sequel::Oracle::Dataset
- Sequel::Oracle::DatasetMethods
- Sequel::Plugins
- Sequel::Plugins::ActiveModel
- Sequel::Plugins::ActiveModel::InstanceMethods
- Sequel::Plugins::AssociationDependencies
- Sequel::Plugins::AssociationDependencies::ClassMethods
- Sequel::Plugins::AssociationDependencies::InstanceMethods
- Sequel::Plugins::AssociationPks
- Sequel::Plugins::AssociationPks::ClassMethods
- Sequel::Plugins::AssociationProxies
- Sequel::Plugins::AssociationProxies::AssociationProxy
- Sequel::Plugins::AssociationProxies::ClassMethods
- Sequel::Plugins::BooleanReaders
- Sequel::Plugins::BooleanReaders::ClassMethods
- Sequel::Plugins::Caching
- Sequel::Plugins::Caching::ClassMethods
- Sequel::Plugins::Caching::InstanceMethods
- Sequel::Plugins::ClassTableInheritance
- Sequel::Plugins::ClassTableInheritance::ClassMethods
- Sequel::Plugins::ClassTableInheritance::InstanceMethods
- Sequel::Plugins::Composition
- Sequel::Plugins::Composition::ClassMethods
- Sequel::Plugins::Composition::InstanceMethods
- Sequel::Plugins::ForceEncoding
- Sequel::Plugins::ForceEncoding::ClassMethods
- Sequel::Plugins::ForceEncoding::InstanceMethods
- Sequel::Plugins::HookClassMethods
- Sequel::Plugins::HookClassMethods::ClassMethods
- Sequel::Plugins::HookClassMethods::InstanceMethods
- Sequel::Plugins::IdentityMap
- Sequel::Plugins::IdentityMap::ClassMethods
- Sequel::Plugins::IdentityMap::InstanceMethods
- Sequel::Plugins::InstanceFilters
- Sequel::Plugins::InstanceFilters::InstanceMethods
- Sequel::Plugins::InstanceHooks
- Sequel::Plugins::InstanceHooks::InstanceMethods
- Sequel::Plugins::LazyAttributes
- Sequel::Plugins::LazyAttributes::ClassMethods
- Sequel::Plugins::LazyAttributes::InstanceMethods
- Sequel::Plugins::ManyThroughMany
- Sequel::Plugins::ManyThroughMany::ClassMethods
- Sequel::Plugins::ManyThroughMany::ManyThroughManyAssociationReflection
- Sequel::Plugins::NestedAttributes
- Sequel::Plugins::NestedAttributes::ClassMethods
- Sequel::Plugins::NestedAttributes::InstanceMethods
- Sequel::Plugins::OptimisticLocking
- Sequel::Plugins::OptimisticLocking::ClassMethods
- Sequel::Plugins::OptimisticLocking::InstanceMethods
- Sequel::Plugins::RcteTree
- Sequel::Plugins::Schema
- Sequel::Plugins::Schema::ClassMethods
- Sequel::Plugins::Serialization
- Sequel::Plugins::Serialization::ClassMethods
- Sequel::Plugins::Serialization::InstanceMethods
- Sequel::Plugins::Sharding
- Sequel::Plugins::Sharding::ClassMethods
- Sequel::Plugins::Sharding::DatasetMethods
- Sequel::Plugins::Sharding::InstanceMethods
- Sequel::Plugins::SingleTableInheritance
- Sequel::Plugins::SingleTableInheritance::ClassMethods
- Sequel::Plugins::SingleTableInheritance::InstanceMethods
- Sequel::Plugins::SkipCreateRefresh
- Sequel::Plugins::SkipCreateRefresh::InstanceMethods
- Sequel::Plugins::StringStripper
- Sequel::Plugins::StringStripper::InstanceMethods
- Sequel::Plugins::Subclasses
- Sequel::Plugins::Subclasses::ClassMethods
- Sequel::Plugins::TacticalEagerLoading
- Sequel::Plugins::TacticalEagerLoading::DatasetMethods
- Sequel::Plugins::TacticalEagerLoading::InstanceMethods
- Sequel::Plugins::Timestamps
- Sequel::Plugins::Timestamps::ClassMethods
- Sequel::Plugins::Timestamps::InstanceMethods
- Sequel::Plugins::Touch
- Sequel::Plugins::Touch::ClassMethods
- Sequel::Plugins::Touch::InstanceMethods
- Sequel::Plugins::TypecastOnLoad
- Sequel::Plugins::TypecastOnLoad::ClassMethods
- Sequel::Plugins::TypecastOnLoad::InstanceMethods
- Sequel::Plugins::UpdatePrimaryKey
- Sequel::Plugins::UpdatePrimaryKey::ClassMethods
- Sequel::Plugins::UpdatePrimaryKey::InstanceMethods
- Sequel::Plugins::ValidationClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods
- Sequel::Plugins::ValidationClassMethods::ClassMethods::Generator
- Sequel::Plugins::ValidationClassMethods::InstanceMethods
- Sequel::Plugins::ValidationHelpers
- Sequel::Plugins::ValidationHelpers::InstanceMethods
- Sequel::PoolTimeout
- Sequel::Postgres
- Sequel::Postgres::Adapter
- Sequel::Postgres::AdapterMethods
- Sequel::Postgres::Database
- Sequel::Postgres::DatabaseMethods
- Sequel::Postgres::Dataset
- Sequel::Postgres::Dataset::ArgumentMapper
- Sequel::Postgres::Dataset::BindArgumentMethods
- Sequel::Postgres::Dataset::PreparedStatementMethods
- Sequel::Postgres::DatasetMethods
- Sequel::Postgres::DatasetMethods::PreparedStatementMethods
- Sequel::PrettyTable
- Sequel::Progress
- Sequel::Progress::DatabaseMethods
- Sequel::Progress::DatasetMethods
- Sequel::Rollback
- Sequel::SQL
- Sequel::SQL::AliasMethods
- Sequel::SQL::AliasedExpression
- Sequel::SQL::BitwiseMethods
- Sequel::SQL::Blob
- Sequel::SQL::BooleanConstant
- Sequel::SQL::BooleanExpression
- Sequel::SQL::BooleanMethods
- Sequel::SQL::CaseExpression
- Sequel::SQL::Cast
- Sequel::SQL::CastMethods
- Sequel::SQL::ColumnAll
- Sequel::SQL::ComplexExpression
- Sequel::SQL::ComplexExpressionMethods
- Sequel::SQL::Constant
- Sequel::SQL::Constants
- Sequel::SQL::Expression
- Sequel::SQL::Function
- Sequel::SQL::GenericComplexExpression
- Sequel::SQL::GenericExpression
- Sequel::SQL::Identifier
- Sequel::SQL::IdentifierMethods
- Sequel::SQL::InequalityMethods
- Sequel::SQL::JoinClause
- Sequel::SQL::JoinOnClause
- Sequel::SQL::JoinUsingClause
- Sequel::SQL::NegativeBooleanConstant
- Sequel::SQL::NoBooleanInputMethods
- Sequel::SQL::NumericExpression
- Sequel::SQL::NumericMethods
- Sequel::SQL::OrderMethods
- Sequel::SQL::OrderedExpression
- Sequel::SQL::PlaceholderLiteralString
- Sequel::SQL::QualifiedIdentifier
- Sequel::SQL::QualifyingMethods
- Sequel::SQL::SQLArray
- Sequel::SQL::StringConcatenationMethods
- Sequel::SQL::StringExpression
- Sequel::SQL::StringMethods
- Sequel::SQL::Subscript
- Sequel::SQL::SubscriptMethods
- Sequel::SQL::VirtualRow
- Sequel::SQL::Window
- Sequel::SQL::WindowFunction
- Sequel::SQLite
- Sequel::SQLite::Database
- Sequel::SQLite::DatabaseMethods
- Sequel::SQLite::Dataset
- Sequel::SQLite::Dataset::ArgumentMapper
- Sequel::SQLite::Dataset::PreparedStatementMethods
- Sequel::SQLite::DatasetMethods
- Sequel::Schema
- Sequel::Schema::AlterTableGenerator
- Sequel::Schema::Generator
- Sequel::ShardedSingleConnectionPool
- Sequel::ShardedThreadedConnectionPool
- Sequel::SimpleMigration
- Sequel::SingleConnectionPool
- Sequel::ThreadLocalTimezones
- Sequel::ThreadedConnectionPool
- Sequel::TimestampMigrator
- Sequel::Timezones
- Sequel::ValidationFailed
- String
- String::Inflections
- Array
- FalseClass
- Hash
- NilClass
- Numeric
- Object
- PGconn
- PGresult
- Proc
- Symbol
- TrueClass

No matching classes.

# New Features

- A few new features were added to query logging. Sequel now includes execution time when logging queries. Queries that raise exceptions are now logged at ERROR level. You can now set the log_warn_duration attribute on the Database instance and queries that take longer than that will be logged at WARN level. By using different log levels, you can now only log queries that raise errors, or only log queries that take a long time.

      # The default - Log all successful queries at INFO level
      DB.log_warn_duration = nil

      # Log all successful queries at WARN level
      DB.log_warn_duration = 0

      # Log successful queries that take the database more than half a
      # second at WARN level, other successful queries at INFO level
      DB.log_warn_duration = 0.5

  All adapters included with Sequel have been modified to support the new logging API. The previous API is still available, so any external adapters should still work, though switching to the new logging API is encouraged.

- Sequel::Model now has a require_modification flag. If not set explicitly, it is enabled by default if the dataset provides an accurate number of rows matched by an update or delete statement. When this setting is enabled, Sequel will raise an exception if you attempt to update or delete a model object and it doesn't end up affecting exactly one row. For example:

      DB.create_table(:as){primary_key :id}
      class A < Sequel::Model; end
      a = A.create

      # delete object from database
      a.delete

      a.require_modification = false
      a.save # no error!
      a.delete # no error!

      a.require_modification = true
      a.save # Sequel::NoExistingObject exception raised
      a.delete # Sequel::NoExistingObject exception raised

  Like many other Sequel::Model settings, this can be set on a global, per class, and per instance level:

      Sequel::Model.require_modification = false # global
      Album.require_modification = true # class
      album.require_modification = false # instance

- An instance_filters plugin was added to the list of built in plugins, allowing you to add arbitrary filters when updating or destroying an instance. This allows you to continue using models when previously you would have had to drop down to using datasets to get the desired behavior:

      class Item < Sequel::Model
        plugin :instance_filters
      end

      # These are two separate objects that represent the same
      # database row.
      i1 = Item.first(:id=>1, :delete_allowed=>false)
      i2 = Item.first(:id=>1, :delete_allowed=>false)

      # Add an instance filter to the object. This filter is in effect
      # until the object is successfully updated or deleted.
      i1.instance_filter(:delete_allowed=>true)

      # Attempting to delete the object where the filter doesn't
      # match any rows raises an error.
      i1.delete # raises Sequel::Error

      # The other object that represents the same row has no
      # instance filters, and can be updated normally.
      i2.update(:delete_allowed=>true)

      # Even though the filter is now still in effect, since the
      # database row has been updated to allow deleting,
      # delete now works.
      i1.delete

- An :after_connect database option is now supported. If provided, the option value should be a proc that takes a single argument. It will be called with the underlying connection object before connection object is added to the connection pool, allowing you to set per connection options in a thread-safe manner.

  This is useful for customizations you want set on every connection that Sequel doesn’t already support. For example, on PostgreSQL if you wanted to set the schema search_path on every connection:

      DB = Sequel.postgres('dbname', :after_connect=>(proc do |conn|
        conn.execute('SET search_path TO schema1,schema2')
      end))

- A :test database option is now supported. If set to true, it automatically calls test_connection to make sure a connection can be made before returning a Database instance. For backwards compatibility reasons, this is not set to true by default, but it is possible that the default will change in a future version of Sequel.

- The Dataset#select_append method was added, which always appends to the existing selected columns. It operates identically to select_more, except in the case that no columns are currently selected:

      ds = DB[:a]
      # SELECT * FROM items
      ds.select_more({:id=>DB[:b].select(:a_id)}.as(:in_b))
      # SELECT id IN (SELECT a_id FROM b) AS in_b FROM a
      ds.select_append({:id=>DB[:b].select(:a_id)}.as(:in_b))
      # SELECT *, id IN (SELECT a_id FROM b) AS in_b FROM a

- The Dataset#provides_accurate_rows_matched? method was added which allows you to see if the dataset will return the actual number of rows matched/affected by an update or delete call.

- Sequel will now emulate DISTINCT ON support using GROUP BY on MySQL. On MySQL, GROUP BY is similar to DISTINCT ON, except that the order of returned rows is not deterministic.

- Support for connecting to Microsoft SQL Server using the JTDS JDBC driver was added to the jdbc adapter.

- JDNI connection strings are now supported in the JDBC adapter.

- The JDBC adapter should now work in situations where driver auto-loading has problems, just as when using Tomcat or Trinidad.

- Sequel’s JDBC adapter schema parsing now supports a :scale option, useful for numeric/decimal columns.

- Sequel’s schema parsing on Microsoft SQL Server now supports :column_size and :scale options.

- When connecting to SQLite, a Database#sqlite_version method is available that gives you the SQLite version as an integer (e.g. 30613 for 3.6.13).

# Other Improvements

- Sequel no longer raises an error if you give Dataset#filter or related method an empty argument such as {}, [], or ". This allows code such as the following to work:

      h = {}
      h[:name] = name if name
      h[:number] = number if number
      ds = ds.filter(h)

  Before, this would raise an error if both name and number were nil.

- Numeric and decimal columns with a 0 scale are now treated as integer columns by the model typecasting code, since such columns cannot store non-integer values.

- Calling Database#disconnect when using the single threaded connection pool no longer raises an error if there is no current connection.

- When using the :ignore_index_errors options to Database#create_table, correctly swallow errors raised by Sequel due to the adapter not supporting the given index type.

- The JDBC adapter no longer leaks ResultSets when retrieving metadata.

- You can now connect to PostgreSQL when using ruby 1.9 with the -Ku switch.

- When using the native MySQL adapter, only tinyint(1) columns are now returned as booleans when using the convert_tinyint_to_bool setting (the default). Previously, all tinyint columns would be converted to booleans if the setting was enabled.

- Correctly handle inserts returning the autogenerated keys when using MySQL JDBC Driver version 5.1.12 with the jdbc adapter.

- The native MySQL adapter now supports :config_default_group and :config_local_infile options.

- When connecting to SQLite, you can provide the :auto_vacuum, :foreign_keys, :synchronous, and :temp_store options for making the appropriate PRAGMA setting on the database in a thread-safe manner. The previous thread-unsafe PRAGMA setting methods are available, but their use is discouraged.

- Sequel will not enable savepoints when connecting to SQLite unless the version is 3.6.8 or greater.

- Using limit with distinct now works correctly on Microsoft SQL Server.

- Database#rename_table now works correctly on Microsoft SQL Server.

- If you specify an explicit :provider when using the ADO adapter, transactions will now work correctly. The default :provider uses a new native connection for each query, so it cannot work with transactions, or things like temporary tables.

- If you specify an explicit :provider when connecting to Microsoft SQL Server using the ADO adapter (e.g. SQLNCLI10 or SQLNCLI), Sequel is now able to provide an accurate number of rows modified and deleted.

- Using set_column_allow_null with a decimal column with a precision and scale now works correctly when connecting to Microsoft SQL Server.

- You can now connect to Microsoft SQL Server using the dbi adapter.

- Sequel now recognizes the NUMBER database type as a synonym for NUMERIC and DECIMAL, which may help some Oracle users.

- Transactions can now be rolled back correctly when connecting to Oracle via JDBC.

- The active_model plugin now supports ActiveModel 3.0.0beta2.

- Many documentation improvements were made, including the addition of a dataset basics guide, an association basics guide, an expanded virtual row guide, and the separation of the Sequel::Dataset RDoc page into sections. Additional, the RDoc class/method documentation now contains links to the appropriate guides.

# Backwards Compatibility

- When connecting to SQLite, Sequel now automatically sets the foreign_keys PRAGMA to true, which will make SQLite 3.6.19+ use database enforced foreign key constraints. If you do not want the database to enforce the foreign key constraints, you should use the :foreign_keys=>false option when connecting to the database.

- Sequel no longer creates #{plugin_name}_opts class, instance, and dataset methods for each plugin loaded. No built-in plugin used them, and I couldn't find an external plugin that did either.

- The Model#associations method is no longer available if the default Associations plugin is not loaded due to the SEQUEL_NO_ASSOCIATIONS constant or environment variable being set.

- DISTINCT ON support is turned off by default, and only enabled when using PostgreSQL, since that appears to be the only database that supports it. Previously, it was enabled by default and most common adapters turned it off.

[Validate]

Generated with the Darkfish Rdoc Generator 2.