### Home Classes Methods

### In Files

- lib/sequel/extensions/query.rb
- lib/sequel/extensions/schema_caching.rb
- lib/sequel/extensions/schema_dumper.rb
- lib/sequel/database.rb
- lib/sequel/database/transactions.rb
- lib/sequel/database/features.rb
- lib/sequel/database/dataset.rb
- lib/sequel/database/logging.rb
- lib/sequel/database/misc.rb
- lib/sequel/database/dataset_defaults.rb
- lib/sequel/database/connecting.rb
- lib/sequel/database/schema_methods.rb
- lib/sequel/database/query.rb

### Parent

Object

### Sections

- 1 - Methods that execute queries and/or return results
- 2 - Methods that modify the database schema
- 3 - Methods that create datasets
- 4 - Methods relating to adapters, connecting, disconnecting, and sharding
- 5 - Methods that set defaults for created datasets
- 6 - Methods relating to logging
- 7 - Miscellaneous methods
- 8 - Methods related to database transactions
- 9 - Methods that describe what the database supports

### Namespace

- MODULE Sequel::Database::ResetIdentifierMangling
- MODULE Sequel::Database::SplitAlterTable
- CLASS Sequel::Database::DatasetClass

### Methods

- ::adapter_class
- ::adapter_scheme
- ::after_initialize
- ::connect
- ::extension
- ::identifier_input_method=
- ::identifier_output_method=
- ::new
- ::register_extension
- ::run_after_initialize
- #<<
- #[]
- #_default_schema
- #adapter_scheme
- #add_column
- #add_index
- #add_servers
- #after_commit
- #after_rollback
- #alter_table
- #alter_table_generator
- #call
- #cast_type_literal
- #connect
- #create_join_table
- #create_or_replace_view
- #create_table
- #create_table!
- #create_table?
- #create_table_generator
- #create_view
- #database_type
- #dataset
- #dataset_class=
- #default_schema
- #default_schema=
- #disconnect
- #disconnect_connection
- #drop_column
- #drop_index
- #drop_join_table
- #drop_table
- #drop_table?
- #drop_view
- #dump_foreign_key_migration
- #dump_indexes_migration
- #dump_schema_cache
- #dump_schema_cache?
- #dump_schema_migration
- #dump_table_schema
- #each_server
- #execute
- #execute_ddl
- #execute_dui
- #execute_insert
- #extend_datasets
- #extension
- #fetch
- #foreign_key_list
- #from
- #from_application_timestamp
- #get
- #global_index_namespace?
- #identifier_input_method=
- #identifier_output_method=
- #in_transaction?
- #indexes
- #inspect
- #literal
- #load_schema_cache
- #load_schema_cache?
- #log_exception
- #log_info
- #log_yield
- #logger=
- #prepared_statement
- #query
- #quote_identifier
- #quote_identifiers=
- #quote_identifiers?
- #remove_servers
- #rename_column
- #rename_table
- #run
- #schema
- #schema_type_class
- #select
- #serial_primary_key_options
- #servers
- #set_column_default
- #set_column_type
- #set_prepared_statement
- #single_threaded?
- #supports_create_table_if_not_exists?
- #supports_deferrable_constraints?
- #supports_deferrable_foreign_key_constraints?
- #supports_drop_table_if_exists?
- #supports_foreign_key_parsing?
- #supports_index_parsing?
- #supports_prepared_transactions?
- #supports_savepoints?
- #supports_savepoints_in_prepared_transactions?
- #supports_schema_parsing?
- #supports_table_listing?
- #supports_transaction_isolation_levels?
- #supports_transactional_ddl?
- #supports_view_listing?
- #synchronize
- #table_exists?
- #tables
- #test_connection
- #timezone
- #to_application_timestamp
- #transaction
- #typecast_value
- #uri
- #url
- #valid_connection?
- #views

### Files

- CHANGELOG
- MIT-LICENSE
- README.rdoc
- active_record.rdoc
- advanced_associations.rdoc
- association_basics.rdoc
- bin_sequel.rdoc
- cheat_sheet.rdoc
- code_order.rdoc
- core_extensions.rdoc
- dataset_basics.rdoc
- dataset_filtering.rdoc
- mass_assignment.rdoc
- migration.rdoc
- model_hooks.rdoc
- object_model.rdoc
- opening_databases.rdoc
- postgresql.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.13.0.txt
- 3.14.0.txt
- 3.15.0.txt
- 3.16.0.txt
- 3.17.0.txt
- 3.18.0.txt
- 3.19.0.txt
- 3.2.0.txt
- 3.20.0.txt
- 3.21.0.txt
- 3.22.0.txt
- 3.23.0.txt
- 3.24.0.txt
- 3.25.0.txt
- 3.26.0.txt
- 3.27.0.txt
- 3.28.0.txt
- 3.29.0.txt
- 3.3.0.txt
- 3.30.0.txt
- 3.31.0.txt
- 3.32.0.txt
- 3.33.0.txt
- 3.34.0.txt
- 3.35.0.txt
- 3.36.0.txt
- 3.37.0.txt
- 3.38.0.txt
- 3.39.0.txt
- 3.4.0.txt
- 3.40.0.txt
- 3.41.0.txt
- 3.42.0.txt
- 3.43.0.txt
- 3.44.0.txt
- 3.45.0.txt
- 3.46.0.txt
- 3.47.0.txt
- 3.48.0.txt
- 3.5.0.txt
- 3.6.0.txt
- 3.7.0.txt
- 3.8.0.txt
- 3.9.0.txt
- schema_modification.rdoc
- security.rdoc
- sharding.rdoc
- sql.rdoc
- testing.rdoc
- thread_safety.rdoc
- transactions.rdoc
- validations.rdoc
- virtual_rows.rdoc

### Class/Module Index

Quicksearch

- Sequel
- Sequel::ADO
- Sequel::ADO::Access
- Sequel::ADO::Access::AdoSchema
- Sequel::ADO::Access::AdoSchema::Column
- Sequel::ADO::Access::DatabaseMethods
- Sequel::ADO::Access::Dataset
- Sequel::ADO::Database
- Sequel::ADO::Dataset
- Sequel::ADO::MSSQL
- Sequel::ADO::MSSQL::DatabaseMethods
- Sequel::ADO::MSSQL::Dataset
- Sequel::ASTTransformer
- Sequel::Access
- Sequel::Access::DatabaseMethods
- Sequel::Access::DatasetMethods
- Sequel::AdapterNotFound
- Sequel::Amalgalite
- Sequel::Amalgalite::Database
- Sequel::Amalgalite::Dataset
- Sequel::Amalgalite::SequelTypeMap
- Sequel::ArbitraryServers
- Sequel::BasicObject
- Sequel::BeforeHookFailed
- Sequel::CheckConstraintViolation
- Sequel::ColumnsIntrospection
- Sequel::ConnectionPool
- Sequel::ConnectionPool::ClassMethods
- Sequel::ConnectionValidator
- Sequel::ConnectionValidator::Retry
- Sequel::ConstraintValidations
- Sequel::ConstraintValidations::AlterTableGeneratorMethods
- Sequel::ConstraintValidations::CreateTableGeneratorMethods
- Sequel::ConstraintValidations::Generator
- Sequel::ConstraintViolation
- Sequel::CoreRefinements
- Sequel::Cubrid
- Sequel::Cubrid::Database
- Sequel::Cubrid::DatabaseMethods
- Sequel::Cubrid::Dataset
- Sequel::Cubrid::DatasetMethods
- Sequel::DB2
- Sequel::DB2::DB2Error
- Sequel::DB2::Database
- Sequel::DB2::DatabaseMethods
- Sequel::DB2::Dataset
- Sequel::DB2::DatasetMethods
- 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::DatabaseMethods
- Sequel::DataObjects::SQLite
- Sequel::DataObjects::SQLite::DatabaseMethods
- Sequel::Database
- Sequel::Database::DatasetClass
- Sequel::Database::ResetIdentifierMangling
- Sequel::Database::SplitAlterTable
- Sequel::DatabaseConnectionError
- Sequel::DatabaseDisconnectError
- Sequel::DatabaseError
- Sequel::DatabaseQuery
- Sequel::Dataset
- Sequel::Dataset::ArgumentMapper
- Sequel::Dataset::DeprecateModifyHash
- Sequel::Dataset::NullDataset
- Sequel::Dataset::Nullifiable
- Sequel::Dataset::Pagination
- Sequel::Dataset::PreparedStatementMethods
- Sequel::Dataset::Query
- Sequel::Dataset::SplitArrayNil
- Sequel::Dataset::StoredProcedureMethods
- Sequel::Dataset::StoredProcedures
- Sequel::Dataset::UnnumberedArgumentMapper
- Sequel::DatasetPagination
- Sequel::DatasetPrinter
- Sequel::DatasetQuery
- Sequel::Deprecation
- Sequel::EmptyArrayIgnoreNulls
- Sequel::EmulateOffsetWithReverseAndCount
- Sequel::EmulateOffsetWithRowNumber
- Sequel::Error
- Sequel::Error::AdapterNotFound
- Sequel::Error::InvalidOperation
- Sequel::Error::InvalidValue
- Sequel::Error::PoolTimeoutError
- Sequel::Error::Rollback
- Sequel::EvalInspect
- Sequel::FilterHaving
- Sequel::Firebird
- Sequel::Firebird::Database
- Sequel::Firebird::DatabaseMethods
- Sequel::Firebird::Dataset
- Sequel::Firebird::DatasetMethods
- Sequel::ForeignKeyConstraintViolation
- Sequel::GraphEach
- Sequel::HashAliases
- Sequel::HookFailed
- Sequel::IBMDB
- Sequel::IBMDB::Connection
- Sequel::IBMDB::Connection::Error
- Sequel::IBMDB::Database
- Sequel::IBMDB::Dataset
- Sequel::IBMDB::Dataset::CallableStatementMethods
- Sequel::IBMDB::Dataset::PreparedStatementMethods
- Sequel::IBMDB::Statement
- Sequel::Inflections
- Sequel::Informix
- Sequel::Informix::Database
- Sequel::Informix::DatabaseMethods
- Sequel::Informix::Dataset
- Sequel::Informix::DatasetMethods
- Sequel::IntegerMigrator
- Sequel::InvalidOperation
- Sequel::InvalidValue
- Sequel::JDBC
- Sequel::JDBC::AS400
- Sequel::JDBC::AS400::DatabaseMethods
- Sequel::JDBC::AS400::Dataset
- Sequel::JDBC::Cubrid
- Sequel::JDBC::Cubrid::DatabaseMethods
- Sequel::JDBC::DB2
- Sequel::JDBC::DB2::DatabaseMethods
- Sequel::JDBC::DB2::Dataset
- Sequel::JDBC::Database
- Sequel::JDBC::Dataset
- Sequel::JDBC::Dataset::PreparedStatementMethods
- Sequel::JDBC::Dataset::StoredProcedureMethods
- Sequel::JDBC::Dataset::TYPE_TRANSLATOR
- Sequel::JDBC::Derby
- Sequel::JDBC::Derby::DatabaseMethods
- Sequel::JDBC::Derby::Dataset
- Sequel::JDBC::Firebird
- Sequel::JDBC::Firebird::DatabaseMethods
- Sequel::JDBC::H2
- Sequel::JDBC::H2::DatabaseMethods
- Sequel::JDBC::H2::Dataset
- Sequel::JDBC::HSQLDB
- Sequel::JDBC::HSQLDB::DatabaseMethods
- Sequel::JDBC::HSQLDB::Dataset
- Sequel::JDBC::Informix
- Sequel::JDBC::Informix::DatabaseMethods
- Sequel::JDBC::JTDS
- Sequel::JDBC::JTDS::DatabaseMethods
- Sequel::JDBC::JTDS::Dataset
- Sequel::JDBC::JavaLang
- Sequel::JDBC::JavaSQL
- Sequel::JDBC::JavaxNaming
- Sequel::JDBC::MSSQL
- Sequel::JDBC::MSSQL::DatabaseMethods
- Sequel::JDBC::MySQL
- Sequel::JDBC::MySQL::DatabaseMethods
- Sequel::JDBC::Oracle
- Sequel::JDBC::Oracle::DatabaseMethods
- Sequel::JDBC::Oracle::Dataset
- Sequel::JDBC::Postgres
- Sequel::JDBC::Postgres::DatabaseMethods
- Sequel::JDBC::Postgres::Dataset
- Sequel::JDBC::Postgres::Dataset::PGArrayConverter
- Sequel::JDBC::Progress
- Sequel::JDBC::Progress::DatabaseMethods
- Sequel::JDBC::SQLServer
- Sequel::JDBC::SQLServer::DatabaseMethods
- Sequel::JDBC::SQLServer::DatabaseMethods::MetadataDatasetMethods
- Sequel::JDBC::SQLite
- Sequel::JDBC::SQLite::DatabaseMethods
- Sequel::JDBC::Transactions
- Sequel::LiteralString
- Sequel::LooserTypecasting
- Sequel::MSSQL
- Sequel::MSSQL::DatabaseMethods
- Sequel::MSSQL::DatasetMethods
- Sequel::Metaprogramming
- Sequel::Migration
- Sequel::MigrationAlterTableReverser
- Sequel::MigrationDSL
- Sequel::MigrationReverser
- Sequel::Migrator
- Sequel::Migrator::Error
- Sequel::Migrator::NotCurrentError
- Sequel::Mock
- Sequel::Mock::Connection
- Sequel::Mock::Database
- Sequel::Mock::Dataset
- Sequel::Model
- Sequel::Model::Associations
- Sequel::Model::Associations::AssociationDatasetMethods
- Sequel::Model::Associations::AssociationReflection
- Sequel::Model::Associations::ClassMethods
- Sequel::Model::Associations::DatasetMethods
- Sequel::Model::Associations::EagerGraphLoader
- 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::DatasetModule
- Sequel::Model::Errors
- Sequel::Model::InstanceMethods
- Sequel::MySQL
- Sequel::MySQL::Database
- Sequel::MySQL::DatabaseMethods
- Sequel::MySQL::Dataset
- Sequel::MySQL::DatasetMethods
- Sequel::MySQL::PreparedStatements
- Sequel::MySQL::PreparedStatements::DatabaseMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods::CallableStatementMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods::PreparedStatementMethods
- Sequel::MySQL::PreparedStatements::DatasetMethods::StoredProcedureMethods
- Sequel::Mysql2
- Sequel::Mysql2::Database
- Sequel::Mysql2::Dataset
- Sequel::NamedTimezones
- Sequel::NamedTimezones::DatabaseMethods
- Sequel::NoExistingObject
- Sequel::NoMatchingRow
- Sequel::NotImplemented
- Sequel::NotNullConstraintViolation
- 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::Dataset::ArgumentMapper
- Sequel::Oracle::Dataset::BindArgumentMethods
- Sequel::Oracle::Dataset::PreparedStatementMethods
- Sequel::Oracle::DatasetMethods
- Sequel::Plugins
- Sequel::Plugins::ActiveModel
- Sequel::Plugins::ActiveModel::ClassMethods
- Sequel::Plugins::ActiveModel::Errors
- Sequel::Plugins::ActiveModel::InstanceMethods
- Sequel::Plugins::AfterInitialize
- Sequel::Plugins::AfterInitialize::ClassMethods
- Sequel::Plugins::AfterInitialize::InstanceMethods
- Sequel::Plugins::AssociationAutoreloading
- Sequel::Plugins::AssociationAutoreloading::ClassMethods
- Sequel::Plugins::AssociationAutoreloading::InstanceMethods
- Sequel::Plugins::AssociationDependencies
- Sequel::Plugins::AssociationDependencies::ClassMethods
- Sequel::Plugins::AssociationDependencies::InstanceMethods
- Sequel::Plugins::AssociationPks
- Sequel::Plugins::AssociationPks::ClassMethods
- Sequel::Plugins::AssociationPks::InstanceMethods
- Sequel::Plugins::AssociationProxies
- Sequel::Plugins::AssociationProxies::AssociationProxy
- Sequel::Plugins::AssociationProxies::ClassMethods
- Sequel::Plugins::AutoValidations
- Sequel::Plugins::AutoValidations::ClassMethods
- Sequel::Plugins::AutoValidations::InstanceMethods
- Sequel::Plugins::BlacklistSecurity
- Sequel::Plugins::BlacklistSecurity::ClassMethods
- Sequel::Plugins::BlacklistSecurity::InstanceMethods
- 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::ConstraintValidations
- Sequel::Plugins::ConstraintValidations::ClassMethods
- Sequel::Plugins::ConstraintValidations::DatabaseMethods
- Sequel::Plugins::ConstraintValidations::InstanceMethods
- Sequel::Plugins::DatasetAssociations
- Sequel::Plugins::DatasetAssociations::ClassMethods
- Sequel::Plugins::DatasetAssociations::DatasetMethods
- Sequel::Plugins::DefaultsSetter
- Sequel::Plugins::DefaultsSetter::ClassMethods
- Sequel::Plugins::DefaultsSetter::InstanceMethods
- Sequel::Plugins::Dirty
- Sequel::Plugins::Dirty::InstanceMethods
- Sequel::Plugins::EagerEach
- Sequel::Plugins::EagerEach::DatasetMethods
- Sequel::Plugins::ErrorSplitter
- Sequel::Plugins::ErrorSplitter::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::InputTransformer
- Sequel::Plugins::InputTransformer::ClassMethods
- Sequel::Plugins::InputTransformer::InstanceMethods
- Sequel::Plugins::InstanceFilters
- Sequel::Plugins::InstanceFilters::Error
- Sequel::Plugins::InstanceFilters::InstanceMethods
- Sequel::Plugins::InstanceHooks
- Sequel::Plugins::InstanceHooks::InstanceMethods
- Sequel::Plugins::JsonSerializer
- Sequel::Plugins::JsonSerializer::ClassMethods
- Sequel::Plugins::JsonSerializer::DatasetMethods
- Sequel::Plugins::JsonSerializer::InstanceMethods
- Sequel::Plugins::JsonSerializer::Literal
- Sequel::Plugins::LazyAttributes
- Sequel::Plugins::LazyAttributes::ClassMethods
- Sequel::Plugins::LazyAttributes::InstanceMethods
- Sequel::Plugins::List
- Sequel::Plugins::List::ClassMethods
- Sequel::Plugins::List::InstanceMethods
- Sequel::Plugins::ManyThroughMany
- Sequel::Plugins::ManyThroughMany::ClassMethods
- Sequel::Plugins::ManyThroughMany::DatasetMethods
- Sequel::Plugins::ManyThroughMany::ManyThroughManyAssociationReflection
- Sequel::Plugins::ManyToOnePkLookup
- Sequel::Plugins::ManyToOnePkLookup::ClassMethods
- Sequel::Plugins::ManyToOnePkLookup::InstanceMethods
- Sequel::Plugins::NestedAttributes
- Sequel::Plugins::NestedAttributes::ClassMethods
- Sequel::Plugins::NestedAttributes::InstanceMethods
- Sequel::Plugins::OptimisticLocking
- Sequel::Plugins::OptimisticLocking::ClassMethods
- Sequel::Plugins::OptimisticLocking::InstanceMethods
- Sequel::Plugins::PgRow
- Sequel::Plugins::PgRow::ClassMethods
- Sequel::Plugins::PgRow::DatabaseMethods
- Sequel::Plugins::PgRow::InstanceMethods
- Sequel::Plugins::PgTypecastOnLoad
- Sequel::Plugins::PgTypecastOnLoad::ClassMethods
- Sequel::Plugins::PgTypecastOnLoad::InstanceMethods
- Sequel::Plugins::PreparedStatements
- Sequel::Plugins::PreparedStatements::ClassMethods
- Sequel::Plugins::PreparedStatements::InstanceMethods
- Sequel::Plugins::PreparedStatementsAssociations
- Sequel::Plugins::PreparedStatementsAssociations::ClassMethods
- Sequel::Plugins::PreparedStatementsAssociations::InstanceMethods
- Sequel::Plugins::PreparedStatementsSafe
- Sequel::Plugins::PreparedStatementsSafe::ClassMethods
- Sequel::Plugins::PreparedStatementsSafe::InstanceMethods
- Sequel::Plugins::PreparedStatementsWithPk
- Sequel::Plugins::PreparedStatementsWithPk::ClassMethods
- Sequel::Plugins::PreparedStatementsWithPk::DatasetMethods
- Sequel::Plugins::RcteTree
- Sequel::Plugins::Schema
- Sequel::Plugins::Schema::ClassMethods
- Sequel::Plugins::Scissors
- Sequel::Plugins::Scissors::ClassMethods
- Sequel::Plugins::Serialization
- Sequel::Plugins::Serialization::ClassMethods
- Sequel::Plugins::Serialization::InstanceMethods
- Sequel::Plugins::SerializationModificationDetection
- Sequel::Plugins::SerializationModificationDetection::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::StaticCache
- Sequel::Plugins::StaticCache::ClassMethods
- Sequel::Plugins::StringStripper
- Sequel::Plugins::StringStripper::ClassMethods
- 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::Tree
- Sequel::Plugins::Tree::ClassMethods
- Sequel::Plugins::Tree::InstanceMethods
- Sequel::Plugins::Tree::SingleRoot
- Sequel::Plugins::Tree::SingleRoot::ClassMethods
- Sequel::Plugins::Tree::SingleRoot::InstanceMethods
- Sequel::Plugins::Tree::TreeMultipleRootError
- Sequel::Plugins::TypecastOnLoad
- Sequel::Plugins::TypecastOnLoad::ClassMethods
- Sequel::Plugins::TypecastOnLoad::InstanceMethods
- Sequel::Plugins::UnlimitedUpdate
- Sequel::Plugins::UnlimitedUpdate::InstanceMethods
- Sequel::Plugins::UpdatePrimaryKey
- 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::Plugins::XmlSerializer
- Sequel::Plugins::XmlSerializer::ClassMethods
- Sequel::Plugins::XmlSerializer::DatasetMethods
- Sequel::Plugins::XmlSerializer::InstanceMethods
- Sequel::PoolTimeout
- Sequel::Postgres
- Sequel::Postgres::Adapter
- Sequel::Postgres::AlterTableGenerator
- Sequel::Postgres::ArrayOp
- Sequel::Postgres::ArrayOpMethods
- Sequel::Postgres::AutoParameterize
- Sequel::Postgres::AutoParameterize::DatabaseMethods
- Sequel::Postgres::AutoParameterize::DatasetMethods
- Sequel::Postgres::AutoParameterize::StringWithArray
- Sequel::Postgres::CreateTableGenerator
- 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::Postgres::ExclusionConstraintViolation
- Sequel::Postgres::HStore
- Sequel::Postgres::HStore::DatabaseMethods
- Sequel::Postgres::HStore::Parser
- Sequel::Postgres::HStoreOp
- Sequel::Postgres::HStoreOpMethods
- Sequel::Postgres::InetDatabaseMethods
- Sequel::Postgres::InetDatasetMethods
- Sequel::Postgres::IntervalDatabaseMethods
- Sequel::Postgres::IntervalDatabaseMethods::Parser
- Sequel::Postgres::IntervalDatasetMethods
- Sequel::Postgres::JSONArray
- Sequel::Postgres::JSONDatabaseMethods
- Sequel::Postgres::JSONHash
- Sequel::Postgres::PGArray
- Sequel::Postgres::PGArray::Creator
- Sequel::Postgres::PGArray::DatabaseMethods
- Sequel::Postgres::PGArray::JSONCreator
- Sequel::Postgres::PGArray::Parser
- Sequel::Postgres::PGRange
- Sequel::Postgres::PGRange::DatabaseMethods
- Sequel::Postgres::PGRange::DatasetMethods
- Sequel::Postgres::PGRange::Parser
- Sequel::Postgres::PGRow
- Sequel::Postgres::PGRow::ArrayRow
- Sequel::Postgres::PGRow::DatabaseMethods
- Sequel::Postgres::PGRow::HashRow
- Sequel::Postgres::PGRow::Parser
- Sequel::Postgres::PGRow::Splitter
- Sequel::Postgres::PGRowOp
- Sequel::Postgres::PGRowOp::ExpressionMethods
- Sequel::Postgres::RangeOp
- Sequel::Postgres::RangeOpMethods
- Sequel::Postgres::StatementCache
- Sequel::Postgres::StatementCache::AdapterMethods
- Sequel::Postgres::StatementCache::DatabaseMethods
- Sequel::Postgres::StatementCache::Statement
- Sequel::Postgres::StatementCache::StatementCache
- Sequel::PrettyTable
- Sequel::Progress
- Sequel::Progress::DatabaseMethods
- Sequel::Progress::DatasetMethods
- Sequel::Qualifier
- Sequel::QueryLiterals
- 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::Builders
- 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::DateAdd
- Sequel::SQL::DateAdd::DatasetMethods
- Sequel::SQL::DelayedEvaluation
- Sequel::SQL::EmulatedFunction
- Sequel::SQL::Expression
- Sequel::SQL::Function
- Sequel::SQL::GenericExpression
- Sequel::SQL::Identifier
- 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::OperatorBuilders
- 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::ValueList
- Sequel::SQL::VirtualRow
- Sequel::SQL::Window
- Sequel::SQL::WindowFunction
- Sequel::SQL::Wrapper
- Sequel::SQLTime
- Sequel::SQLite
- Sequel::SQLite::Database
- Sequel::SQLite::DatabaseMethods
- Sequel::SQLite::Dataset
- Sequel::SQLite::Dataset::ArgumentMapper
- Sequel::SQLite::Dataset::BindArgumentMethods
- Sequel::SQLite::Dataset::PreparedStatementMethods
- Sequel::SQLite::DatasetMethods
- Sequel::Schema
- Sequel::Schema::AlterTableGenerator
- Sequel::Schema::CreateTableGenerator
- Sequel::Schema::Generator
- Sequel::SchemaCaching
- Sequel::SchemaDumper
- Sequel::SelectRemove
- Sequel::Sequel3DatasetMethods
- Sequel::SerializationFailure
- Sequel::ServerBlock
- Sequel::SetOverrides
- Sequel::ShardedSingleConnectionPool
- Sequel::ShardedThreadedConnectionPool
- Sequel::SimpleMigration
- Sequel::SingleConnectionPool
- Sequel::Swift
- Sequel::Swift::Database
- Sequel::Swift::Dataset
- Sequel::Swift::MySQL
- Sequel::Swift::MySQL::DatabaseMethods
- Sequel::Swift::MySQL::Dataset
- Sequel::Swift::Postgres
- Sequel::Swift::Postgres::DatabaseMethods
- Sequel::Swift::SQLite
- Sequel::Swift::SQLite::DatabaseMethods
- Sequel::Swift::SQLite::Dataset
- Sequel::ThreadLocalTimezones
- Sequel::ThreadedConnectionPool
- Sequel::ThreadedServerBlock
- Sequel::TimestampMigrator
- Sequel::Timezones
- Sequel::TinyTDS
- Sequel::TinyTDS::Database
- Sequel::TinyTDS::Dataset
- Sequel::TinyTDS::Dataset::ArgumentMapper
- Sequel::TinyTDS::Dataset::PreparedStatementMethods
- Sequel::ToDot
- Sequel::ToDot::DatasetMethods
- Sequel::UnbindDuplicate
- Sequel::Unbinder
- Sequel::UndefinedAssociation
- Sequel::UniqueConstraintViolation
- Sequel::UnthreadedServerBlock
- Sequel::ValidationFailed
- String
- String::Inflections
- Array
- FalseClass
- Hash
- NilClass
- Numeric
- Object
- PGconn
- PGresult
- Range
- Symbol
- TrueClass

No matching classes.

# Sequel::Database

A Database object represents a virtual connection to a database. The Database class is meant to be subclassed by database adapters in order to provide the functionality needed for executing queries.

### Public Instance Methods

dump_foreign_key_migration(options={}) click to toggle source

Dump foreign key constraints for all tables as a migration. This complements the :foreign_keys=>false option to dump_schema_migration. This only dumps the constraints (not the columns) using alter_table/add_foreign_key with an array of columns.

Note that the migration this produces does not have a down block, so you cannot reverse it.

    # File lib/sequel/extensions/schema_dumper.rb, line 25
    def dump_foreign_key_migration(options={})
      Sequel::Deprecation.deprecate('Loading the schema_dumper extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaDumper)
      ts = tables(options)
      Sequel.migration do  change do#{ts.sort_by{|t| t.to_s}.map{|t| dump_table_foreign_keys(t)}.reject{|x| x == ''}.join("\n\n").gsub(/^/o, '    ')}  endend
    end

dump_indexes_migration(options={}) click to toggle source

Dump indexes for all tables as a migration. This complements the :indexes=>false option to dump_schema_migration. Options:

:same_db | Create a dump for the same database type, so don't ignore errors if the index statements fail.
:index_names | If set to false, don't record names of indexes. If set to :namespace, prepend the table name to the index name if the database does not use a global index namespace.

    # File lib/sequel/extensions/schema_dumper.rb, line 44
    def dump_indexes_migration(options={})
      Sequel::Deprecation.deprecate('Loading the schema_dumper extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaDumper)
      ts = tables(options)
      Sequel.migration do  change do#{ts.sort_by{|t| t.to_s}.map{|t| dump_table_indexes(t, :add_index, options)}.reject{|x| x == ''}.join("\n\n").gsub(/^/o, '    ')}  endend
    end

dump_schema_cache(file) click to toggle source

Dump the cached schema to the filename given in Marshal format.

    # File lib/sequel/extensions/schema_caching.rb, line 51
    def dump_schema_cache(file)
      Sequel::Deprecation.deprecate('Loading the schema_caching extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaCaching)
      File.open(file, 'wb'){|f| f.write(Marshal.dump(@schemas))}
      nil
    end

dump_schema_cache?(file) click to toggle source

Dump the cached schema to the filename given unless the file already exists.

    # File lib/sequel/extensions/schema_caching.rb, line 59
    def dump_schema_cache?(file)
      Sequel::Deprecation.deprecate('Loading the schema_caching extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaCaching)
      dump_schema_cache(file) unless File.exist?(file)
    end

dump_schema_migration(options={}) click to toggle source

Return a string that contains a Sequel::Migration subclass that when run would recreate the database structure. Options:

:same_db | Don't attempt to translate database types to ruby types. If this isn't set to true, all database types will be translated to ruby types, but there is no guarantee that the migration generated will yield the same type. Without this set, types that aren't recognized will be translated to a string-like type.
:foreign_keys | If set to false, don't dump foreign_keys (they can be

    added later via #dump_foreign_key_migration)

:indexes | If set to false, don't dump indexes (they can be added later via dump_index_migration).
:index_names | If set to false, don't record names of indexes. If set to :namespace, prepend the table name to the index name.

    # File lib/sequel/extensions/schema_dumper.rb, line 69
    def dump_schema_migration(options={})
      Sequel::Deprecation.deprecate('Loading the schema_dumper extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaDumper)
      options = options.dup
      if options[:indexes] == false && !options.has_key?(:foreign_keys)
        # Unless foreign_keys option is specifically set, disable if indexes
        # are disabled, as foreign keys that point to non-primary keys rely
        # on unique indexes being created first
        options[:foreign_keys] = false
      end

      ts = sort_dumped_tables(tables(options), options)
      skipped_fks = if sfk = options[:skipped_foreign_keys]
        # Handle skipped foreign keys by adding them at the end via
        # alter_table/add_foreign_key.  Note that skipped foreign keys
        # probably result in a broken down migration.
        sfka = sfk.sort_by{|table, fks| table.to_s}.map{|table, fks| dump_add_fk_constraints(table, fks.values)}
        sfka.join("\n\n").gsub(/^/, '    ') unless sfka.empty?
      end

      Sequel.migration do  change do#{ts.map{|t| dump_table_schema(t, options)}.join("\n\n").gsub(/^/o, '    ')}#{"\n    \n" if skipped_fks}#{skipped_fks}  endend
    end

dump_table_schema(table, options={}) click to toggle source

Return a string with a create table block that will recreate the given table's schema. Takes the same options as dump_schema_migration.

    # File lib/sequel/extensions/schema_dumper.rb, line 99
    def dump_table_schema(table, options={})
      Sequel::Deprecation.deprecate('Loading the schema_dumper extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaDumper)
      table = table.value.to_s if table.is_a?(SQL::Identifier)
      gen = dump_table_generator(table, options)
      commands = [gen.dump_columns, gen.dump_constraints, gen.dump_indexes].reject{|x| x == ''}.join("\n\n")
      "create_table(#{table.inspect}#{', :ignore_index_errors=>true' if !options[:same_db] && options[:indexes] != false && !gen.indexes.empty?}) do\n#{commands.gsub(/^/o, '  ')}\nend"
    end

load_schema_cache(file) click to toggle source

Replace the schema cache with the data from the given file, which should be in Marshal format.

    # File lib/sequel/extensions/schema_caching.rb, line 66
    def load_schema_cache(file)
      Sequel::Deprecation.deprecate('Loading the schema_caching extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaCaching)
      @schemas = Marshal.load(File.read(file))
      nil
    end

load_schema_cache?(file) click to toggle source

Replace the schema cache with the data from the given file if the file exists.

    # File lib/sequel/extensions/schema_caching.rb, line 74
    def load_schema_cache?(file)
      Sequel::Deprecation.deprecate('Loading the schema_caching extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(SchemaCaching)
      load_schema_cache(file) if File.exist?(file)
    end

query(&block) click to toggle source

Return a dataset modified by the query block

    # File lib/sequel/extensions/query.rb, line 24
    def query(&block)
      Sequel::Deprecation.deprecate('Loading the query extension globally', "Please use Database#extension to load the extension into this database") unless is_a?(DatabaseQuery)
      dataset.query(&block)
    end

## 1 - Methods that execute queries and/or return results ↑ top

This methods generally execute SQL code on the database server.

### Constants

COLUMN_SCHEMA_DATETIME_TYPES
COLUMN_SCHEMA_STRING_TYPES
CURRENT_TIMESTAMP_RE
STRING_DEFAULT_RE

### Attributes

cache_schema[RW]

Whether the schema should be cached for this database. True by default for performance, can be set to false to always issue a database query to get the schema.

prepared_statements[R]

The prepared statement object hash for this database, keyed by name symbol

### Public Instance Methods

<<(sql) click to toggle source

Runs the supplied SQL statement string on the database server. Returns self so it can be safely chained:

    DB << "UPDATE albums SET artist_id = NULL" << "DROP TABLE artists"

    # File lib/sequel/database/query.rb, line 25
    def <<(sql)
      run(sql)
      self
    end

call(ps_name, hash={}, &block) click to toggle source

Call the prepared statement with the given name with the given hash of arguments.

    DB[:items].filter(:id=>1).prepare(:first, :sa)
    DB.call(:sa) # SELECT * FROM items WHERE id = 1

    # File lib/sequel/database/query.rb, line 35
    def call(ps_name, hash={}, &block)
      prepared_statement(ps_name).call(hash, &block)
    end

execute(sql, opts={}) click to toggle source

Executes the given SQL on the database. This method should be overridden in descendants. This method should not be called directly by user code.

    # File lib/sequel/database/query.rb, line 41
    def execute(sql, opts={})
      Sequel::Deprecation.deprecate('Database#execute default implementation and Sequel::NotImplemented', 'All database instances can be assumed to implement execute')
      raise NotImplemented, "#execute should be overridden by adapters"
    end

execute_ddl(sql, opts={}, &block) click to toggle source

Method that should be used when submitting any DDL (Data Definition Language) SQL, such as `create_table`. By default, calls `execute_dui`. This method should not be called directly by user code.

    # File lib/sequel/database/query.rb, line 49
    def execute_ddl(sql, opts={}, &block)
      execute_dui(sql, opts, &block)
    end

execute_dui(sql, opts={}, &block) click to toggle source

Method that should be used when issuing a DELETE, UPDATE, or INSERT statement. By default, calls execute. This method should not be called directly by user code.

    # File lib/sequel/database/query.rb, line 56
    def execute_dui(sql, opts={}, &block)
      execute(sql, opts, &block)
    end

execute_insert(sql, opts={}, &block) click to toggle source

Method that should be used when issuing a INSERT statement. By default, calls execute_dui. This method should not be called directly by user code.

    # File lib/sequel/database/query.rb, line 63
    def execute_insert(sql, opts={}, &block)
      execute_dui(sql, opts, &block)
    end

foreign_key_list(table, opts={}) click to toggle source

Returns an array of hashes containing foreign key information from the table. Each hash will contain at least the following fields:

:columns | An array of columns in the given table
:table | The table referenced by the columns
:key | An array of columns referenced (in the table specified by :table), but can be nil on certain adapters if the primary key is referenced.

The hash may also contain entries for:

:deferrable | Whether the constraint is deferrable
:name | The name of the constraint
:on_delete | The action to take ON DELETE
:on_update | The action to take ON UPDATE

    # File lib/sequel/database/query.rb, line 81
    def foreign_key_list(table, opts={})
      Sequel::Deprecation.deprecate('Database#foreign_key_list default implementation and Sequel::NotImplemented', 'Use Database#supports_foreign_key_parsing? to check for support')
      raise NotImplemented, "#foreign_key_list should be overridden by adapters"
    end

get(*args, &block) click to toggle source

Returns a single value from the database, e.g.:

    DB.get(1) # SELECT 1
    # => 1
    DB.get{server_version{}} # SELECT server_version()

    # File lib/sequel/database/query.rb, line 91
    def get(*args, &block)
      @default_dataset.get(*args, &block)
    end

indexes(table, opts={}) click to toggle source

Return a hash containing index information for the table. Hash keys are index name symbols. Values are subhashes with two keys, :columns and :unique. The value of :columns is an array of symbols of column names. The value of :unique is true or false depending on if the index is unique.

Should not include the primary key index, functional indexes, or partial indexes.

    DB.indexes(:artists)
    # => {:artists_name_ukey=>{:columns=>[:name], :unique=>true}}

    # File lib/sequel/database/query.rb, line 104
    def indexes(table, opts={})
      Sequel::Deprecation.deprecate('Database#indexes default implementation and Sequel::NotImplemented', 'Use Database#supports_index_parsing? to check for support')
      raise NotImplemented, "#indexes should be overridden by adapters"
    end

run(sql, opts={}) click to toggle source

Runs the supplied SQL statement string on the database server. Returns nil. Options:

:server | The server to run the SQL on.

    DB.run("SET some_server_variable = 42")

    # File lib/sequel/database/query.rb, line 114
    def run(sql, opts={})
      execute_ddl(sql, opts)
      nil
    end

schema(table, opts={}) click to toggle source

Returns the schema for the given table as an array with all members being arrays of length 2, the first member being the column name, and the second member being a hash of column information. The table argument can also be a dataset, as long as it only has one table. Available options are:

:reload | Ignore any cached results, and get fresh information from the database.
:schema | An explicit schema to use. It may also be implicitly provided via the table name.

If schema parsing is supported by the database, the column information should hash at least contain the following entries:

:allow_null | Whether NULL is an allowed value for the column.
:db_type | The database type for the column, as a database specific string.
:default | The database default for the column, as a database specific string.
:primary_key | Whether the columns is a primary key column. If this column is not present, it means that primary key information is unavailable, not that the column is not a primary key.
:ruby_default | The database default for the column, as a ruby object. In many cases, complex database defaults cannot be parsed into ruby objects, in which case nil will be used as the value.
:type | A symbol specifying the type, such as :integer or :string.

Example:

    DB.schema(:artists)
    # [[:id,
    #   {:type=>:integer,
    #    :primary_key=>true,
    #    :default=>"nextval('artist_id_seq'::regclass)",
    #    :ruby_default=>nil,
    #    :db_type=>"integer",
    #    :allow_null=>false}],
    #  [:name,
    #   {:type=>:string,
    #    :primary_key=>false,
    #    :default=>nil,
    #    :ruby_default=>nil,
    #    :db_type=>"text",
    #    :allow_null=>false}]]

    # File lib/sequel/database/query.rb, line 159
    def schema(table, opts={})
      raise(Error, 'schema parsing is not implemented on this database') unless supports_schema_parsing?

      opts = opts.dup
      tab = if table.is_a?(Dataset)
        o = table.opts
        from = o[:from]
        raise(Error, "can only parse the schema for a dataset with a single from table") unless from && from.length == 1 && !o.include?(:join) && !o.include?(:sql)
        table.first_source_table
      else
        table
      end

      qualifiers = split_qualifiers(tab)
      table_name = qualifiers.pop
      sch = qualifiers.pop
      information_schema_schema = case qualifiers.length
      when 1
        Sequel.identifier(*qualifiers)
      when 2
        Sequel.qualify(*qualifiers)
      end

      if table.is_a?(Dataset)
        quoted_name = table.literal(tab)
        opts[:dataset] = table
      else
        quoted_name = schema_utility_dataset.literal(table)
      end

      opts[:schema] = sch if sch && !opts.include?(:schema)
      opts[:information_schema_schema] = information_schema_schema if information_schema_schema && !opts.include?(:information_schema_schema)

      Sequel.synchronize{@schemas.delete(quoted_name)} if opts[:reload]
      if v = Sequel.synchronize{@schemas[quoted_name]}
        return v
      end

      cols = schema_parse_table(table_name, opts)
      raise(Error, 'schema parsing returned no columns, table probably doesn\t exist') if cols.nil? || cols.empty?
      cols.each{|_,c| c[:ruby_default] = column_schema_to_ruby_default(c[:default], c[:type])}
      Sequel.synchronize{@schemas[quoted_name] = cols} if cache_schema
      cols
    end

table_exists?(name) click to toggle source

Returns true if a table with the given name exists. This requires a query to the database.

    DB.table_exists?(:foo) # => false
    # SELECT NULL FROM foo LIMIT 1

Note that since this does a SELECT from the table, it can give false negatives if you don't have permission to SELECT from the table.

    # File lib/sequel/database/query.rb, line 212
    def table_exists?(name)
      sch, table_name = schema_and_table(name)
      name = SQL::QualifiedIdentifier.new(sch, table_name) if sch
      _table_exists?(from(name))
      true
    rescue DatabaseError
      false
    end

tables(opts={}) click to toggle source

Return all tables in the database as an array of symbols.

    DB.tables # => [:albums, :artists]

    # File lib/sequel/database/query.rb, line 224
    def tables(opts={})
      Sequel::Deprecation.deprecate('Database#tables default implementation and Sequel::NotImplemented', 'Use Database#supports_table_listing? to check for support')
      raise NotImplemented, "#tables should be overridden by adapters"
    end

views(opts={}) click to toggle source

Return all views in the database as an array of symbols.

    DB.views # => [:gold_albums, :artists_with_many_albums]

    # File lib/sequel/database/query.rb, line 232
    def views(opts={})
      Sequel::Deprecation.deprecate('Database#views default implementation and Sequel::NotImplemented', 'Use Database#supports_view_listing? to check for support')
      raise NotImplemented, "#views should be overridden by adapters"
    end

## 2 - Methods that modify the database schema ↑ top

These methods execute code on the database that modifies the database's schema.

### Constants

AUTOINCREMENT
COLUMN_DEFINITION_ORDER

  The order of column modifiers to use when defining a column.

COMBINABLE_ALTER_TABLE_OPS

  The alter table operations that are combinable.

COMMA_SEPARATOR
DEFAULT_JOIN_TABLE_COLUMN_OPTIONS

  The default options for join table columns.

NOT_NULL
NULL
PRIMARY_KEY
TEMPORARY
UNDERSCORE
UNIQUE
UNSIGNED

### Public Instance Methods

add_column(table, *args) click to toggle source

Adds a column to the specified table. This method expects a column name, a datatype and optionally a hash with additional constraints and options:

    DB.add_column :items, :name, :text, :unique => true, :null => false
    DB.add_column :items, :category, :text, :default => 'ruby'

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 36
    def add_column(table, *args)
      alter_table(table) {add_column(*args)}
    end

add_index(table, columns, options={}) click to toggle source

Adds an index to a table for the given columns:

    DB.add_index :posts, :title
    DB.add_index :posts, [:author, :title], :unique => true

Options:

:ignore_errors | Ignore any DatabaseErrors that are raised

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 49
    def add_index(table, columns, options={})
      e = options[:ignore_errors]
      begin
        alter_table(table){add_index(columns, options)}
      rescue DatabaseError
        raise unless e
      end
    end

alter_table(name, generator=nil, &block) click to toggle source

Alters the given table with the specified block. Example:

    DB.alter_table :items do
      add_column :category, :text, :default => 'ruby'
      drop_column :category
      rename_column :cntr, :counter
      set_column_type :value, :float
      set_column_default :value, :float
      add_index [:group, :category]
      drop_index [:group, :category]
    end

Note that `add_column` accepts all the options available for column definitions using `create_table`, and `add_index` accepts all the options available for index definition.

See `Schema::AlterTableGenerator` and the "Migrations and Schema Modification" guide.

    # File lib/sequel/database/schema_methods.rb, line 75
    def alter_table(name, generator=nil, &block)
      generator ||= alter_table_generator(&block)
      remove_cached_schema(name)
      apply_alter_table_generator(name, generator)
      nil
    end

alter_table_generator(&block) click to toggle source

Return a new Schema::AlterTableGenerator instance with the receiver as the database and the given block.

    # File lib/sequel/database/schema_methods.rb, line 84
    def alter_table_generator(&block)
      alter_table_generator_class.new(self, &block)
    end

create_join_table(hash, options={}) click to toggle source

Create a join table using a hash of foreign keys to referenced table names. Example:

    create_join_table(:cat_id=>:cats, :dog_id=>:dogs)
    # CREATE TABLE cats_dogs (
    #  cat_id integer NOT NULL REFERENCES cats,
    #  dog_id integer NOT NULL REFERENCES dogs,
    #  PRIMARY KEY (cat_id, dog_id)
    # )
    # CREATE INDEX cats_dogs_dog_id_cat_id_index ON cats_dogs(dog_id, cat_id)

The primary key and index are used so that almost all operations on the table can benefit from one of the two indexes, and the primary key ensures that entries in the table are unique, which is the typical desire for a join table.

You can provide column options by making the values in the hash be option hashes, so long as the option hashes have a :table entry giving the table referenced:

    create_join_table(:cat_id=>{:table=>:cats, :type=>Bignum}, :dog_id=>:dogs)

You can provide a second argument which is a table options hash:

    create_join_table({:cat_id=>:cats, :dog_id=>:dogs}, :temp=>true)

Some table options are handled specially:

:index_options | The options to pass to the index
:name | The name of the table to create
:no_index | Set to true not to create the second index.
:no_primary_key | Set to true to not create the primary key.

    # File lib/sequel/database/schema_methods.rb, line 120
    def create_join_table(hash, options={})
      keys = hash.keys.sort_by{|k| k.to_s}
      create_table(join_table_name(hash, options), options) do
        keys.each do |key|
          v = hash[key]
          unless v.is_a?(Hash)
            v = {:table=>v}
          end
          v = DEFAULT_JOIN_TABLE_COLUMN_OPTIONS.merge(v)
          foreign_key(key, v)
        end
        primary_key(keys) unless options[:no_primary_key]
        index(keys.reverse, options[:index_options] || {}) unless options[:no_index]
      end
    end

create_or_replace_view(name, source, options = {}) click to toggle source

Creates a view, replacing a view with the same name if one already exists.

    DB.create_or_replace_view(:some_items, "SELECT * FROM items WHERE price < 100")
    DB.create_or_replace_view(:some_items, DB[:items].filter(:category => 'ruby'))

For databases where replacing a view is not natively supported, support is emulated by dropping a view with the same name before creating the view.

    # File lib/sequel/database/schema_methods.rb, line 212
    def create_or_replace_view(name, source, options = {})
      if supports_create_or_replace_view?
        options = options.merge(:replace=>true)
      else
        drop_view(name) rescue nil
      end

      create_view(name, source, options)
    end

create_table(name, options={}, &block) click to toggle source

Creates a table with the columns given in the provided block:

    DB.create_table :posts do
      primary_key :id
      column :title, :text
      String :content
      index :title
    end

General options:

:as | Create the table using the value, which should be either a dataset or a literal SQL string. If this option is used, a block should not be given to the method.
:ignore_index_errors | Ignore any errors when creating indexes.
:temp | Create the table as a temporary table.

MySQL specific options:

:charset | The character set to use for the table.
:collate | The collation to use for the table.
:engine | The table engine to use for the table.

PostgreSQL specific options:

:unlogged | Create the table as an unlogged table.

See `Schema::Generator` and the "Schema Modification" guide.

    # File lib/sequel/database/schema_methods.rb, line 161
    def create_table(name, options={}, &block)
      remove_cached_schema(name)
      options = {:generator=>options} if options.is_a?(Schema::CreateTableGenerator)
      if sql = options[:as]
        raise(Error, "can't provide both :as option and block to create_table") if block
        create_table_as(name, sql, options)
      else
        generator = options[:generator] || create_table_generator(&block)
        create_table_from_generator(name, generator, options)
        create_table_indexes_from_generator(name, generator, options)
        nil
      end
    end

create_table!(name, options={}, &block) click to toggle source

Forcibly create a table, attempting to drop it if it already exists, then creating it.

    DB.create_table!(:a){Integer :a}
    # SELECT NULL FROM a LIMIT 1 -- check existence
    # DROP TABLE a -- drop table if already exists
    # CREATE TABLE a (a integer)

    # File lib/sequel/database/schema_methods.rb, line 181
    def create_table!(name, options={}, &block)
      drop_table?(name)
      create_table(name, options, &block)
    end

create_table?(name, options={}, &block) click to toggle source

Creates the table unless the table already exists.

    DB.create_table?(:a){Integer :a}
    # SELECT NULL FROM a LIMIT 1 -- check existence
    # CREATE TABLE a (a integer) -- if it doesn't already exist

    # File lib/sequel/database/schema_methods.rb, line 191
    def create_table?(name, options={}, &block)
      if supports_create_table_if_not_exists?
        create_table(name, options.merge(:if_not_exists=>true), &block)
      elsif !table_exists?(name)
        create_table(name, options, &block)
      end
    end

create_table_generator(&block) click to toggle source

Return a new Schema::CreateTableGenerator instance with the receiver as the database and the given block.

    # File lib/sequel/database/schema_methods.rb, line 201
    def create_table_generator(&block)
      create_table_generator_class.new(self, &block)
    end

create_view(name, source, options = {}) click to toggle source

Creates a view based on a dataset or an SQL string:

    DB.create_view(:cheap_items, "SELECT * FROM items WHERE price < 100")
    DB.create_view(:ruby_items, DB[:items].filter(:category => 'ruby'))

PostgreSQL/SQLite specific option:

:temp | Create a temporary view, automatically dropped on disconnect.

    # File lib/sequel/database/schema_methods.rb, line 229
    def create_view(name, source, options = {})
      execute_ddl(create_view_sql(name, source, options))
      remove_cached_schema(name)
      nil
    end

drop_column(table, *args) click to toggle source

Removes a column from the specified table:

    DB.drop_column :items, :category

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 240
    def drop_column(table, *args)
      alter_table(table) {drop_column(*args)}
    end

drop_index(table, columns, options={}) click to toggle source

Removes an index for the given table and column/s:

    DB.drop_index :posts, :title
    DB.drop_index :posts, [:author, :title]

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 250
    def drop_index(table, columns, options={})
      alter_table(table){drop_index(columns, options)}
    end

drop_join_table(hash, options={}) click to toggle source

Drop the join table that would have been created with the same arguments to create_join_table:

    drop_join_table(:cat_id=>:cats, :dog_id=>:dogs)
    # DROP TABLE cats_dogs

    # File lib/sequel/database/schema_methods.rb, line 259
    def drop_join_table(hash, options={})
      drop_table(join_table_name(hash, options), options)
    end

drop_table(*names) click to toggle source

Drops one or more tables corresponding to the given names:

    DB.drop_table(:posts) # DROP TABLE posts
    DB.drop_table(:posts, :comments)
    DB.drop_table(:posts, :comments, :cascade=>true)

    # File lib/sequel/database/schema_methods.rb, line 268
    def drop_table(*names)
      options = names.last.is_a?(Hash) ? names.pop : {}
      names.each do |n|
        execute_ddl(drop_table_sql(n, options))
        remove_cached_schema(n)
      end
      nil
    end

drop_table?(*names) click to toggle source

Drops the table if it already exists. If it doesn't exist, does nothing.

    DB.drop_table?(:a)
    # SELECT NULL FROM a LIMIT 1 -- check existence
    # DROP TABLE a -- if it already exists

    # File lib/sequel/database/schema_methods.rb, line 283
    def drop_table?(*names)
      options = names.last.is_a?(Hash) ? names.pop : {}
      if supports_drop_table_if_exists?
        options = options.merge(:if_exists=>true)
        names.each do |name|
          drop_table(name, options)
        end
      else
        names.each do |name|
          drop_table(name, options) if table_exists?(name)
        end
      end
    end

drop_view(*names) click to toggle source

Drops one or more views corresponding to the given names:

    DB.drop_view(:cheap_items)
    DB.drop_view(:cheap_items, :pricey_items)
    DB.drop_view(:cheap_items, :pricey_items, :cascade=>true)

    # File lib/sequel/database/schema_methods.rb, line 302
    def drop_view(*names)
      options = names.last.is_a?(Hash) ? names.pop : {}
      names.each do |n|
        execute_ddl(drop_view_sql(n, options))
        remove_cached_schema(n)
      end
      nil
    end

rename_column(table, *args) click to toggle source

Renames a column in the specified table. This method expects the current column name and the new column name:

    DB.rename_column :items, :cntr, :counter

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 328
    def rename_column(table, *args)
      alter_table(table) {rename_column(*args)}
    end

rename_table(name, new_name) click to toggle source

Renames a table:

    DB.tables #=> [:items]
    DB.rename_table :items, :old_items
    DB.tables #=> [:old_items]

    # File lib/sequel/database/schema_methods.rb, line 316
    def rename_table(name, new_name)
      execute_ddl(rename_table_sql(name, new_name))
      remove_cached_schema(name)
      nil
    end

set_column_default(table, *args) click to toggle source

Sets the default value for the given column in the given table:

    DB.set_column_default :items, :category, 'perl!'

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 337
    def set_column_default(table, *args)
      alter_table(table) {set_column_default(*args)}
    end

set_column_type(table, *args) click to toggle source

Set the data type for the given column in the given table:

    DB.set_column_type :items, :price, :float

See `alter_table`.

    # File lib/sequel/database/schema_methods.rb, line 346
    def set_column_type(table, *args)
      alter_table(table) {set_column_type(*args)}
    end

## 3 - Methods that create datasets ↑ top

These methods all return instances of this database's dataset class.

### Public Instance Methods

[](*args) click to toggle source

Returns a dataset for the database. If the first argument is a string, the method acts as an alias for Database#fetch, returning a dataset for arbitrary SQL, with or without placeholders:

    DB['SELECT * FROM items'].all
    DB['SELECT * FROM items WHERE name = ?', my_name].all

Otherwise, acts as an alias for Database#from, setting the primary table for the dataset:

    DB[:items].sql #=> "SELECT * FROM items"

    # File lib/sequel/database/dataset.rb, line 19
    def [](*args)
      args.first.is_a?(String) ? fetch(*args) : from(*args)
    end

dataset(opts=(no_arg_given=true; nil)) click to toggle source

Returns a blank dataset for this database.

    DB.dataset # SELECT *
    DB.dataset.from(:items) # SELECT * FROM items

    # File lib/sequel/database/dataset.rb, line 27
    def dataset(opts=(no_arg_given=true; nil))
      # REMOVE40
      if no_arg_given
        @dataset_class.new(self)
      else
        @dataset_class.new(self, opts)
      end
    end

fetch(sql, *args, &block) click to toggle source

Fetches records for an arbitrary SQL statement. If a block is given, it is used to iterate over the records:

    DB.fetch('SELECT * FROM items'){|r| p r}

The `fetch` method returns a dataset instance:

    DB.fetch('SELECT * FROM items').all

`fetch` can also perform parameterized queries for protection against SQL injection:

    DB.fetch('SELECT * FROM items WHERE name = ?', my_name).all

    # File lib/sequel/database/dataset.rb, line 49
    def fetch(sql, *args, &block)
      ds = @default_dataset.with_sql(sql, *args)
      ds.each(&block) if block
      ds
    end

from(*args, &block) click to toggle source

Returns a new dataset with the `from` method invoked. If a block is given, it is used as a filter on the dataset.

    DB.from(:items) # SELECT * FROM items
    DB.from(:items){id > 2} # SELECT * FROM items WHERE (id > 2)

    # File lib/sequel/database/dataset.rb, line 60
    def from(*args, &block)
      ds = @default_dataset.from(*args)
      block ? ds.filter(&block) : ds
    end

select(*args, &block) click to toggle source

Returns a new dataset with the select method invoked.

    DB.select(1) # SELECT 1
    DB.select{server_version{}} # SELECT server_version()
    DB.select(:id).from(:items) # SELECT id FROM items

    # File lib/sequel/database/dataset.rb, line 70
    def select(*args, &block)
      @default_dataset.select(*args, &block)
    end

## 4 - Methods relating to adapters, connecting, disconnecting, and sharding ↑ top

This methods involve the Database's connection pool.

### Constants

ADAPTERS

  Array of supported database adapters

### Attributes

single_threaded[RW]

Whether to use the single threaded connection pool by default

pool[R]

The connection pool for this Database instance. All Database instances have their own connection pools.

### Public Class Methods

adapter_class(scheme) click to toggle source

The Database subclass for the given adapter scheme. Raises Sequel::AdapterNotFound if the adapter could not be loaded.

    # File lib/sequel/database/connecting.rb, line 21
    def self.adapter_class(scheme)
      return scheme if scheme.is_a?(Class)

      scheme = scheme.to_s.gsub('-', '_').to_sym

      unless klass = ADAPTER_MAP[scheme]
        # attempt to load the adapter file
        begin
          require "sequel/adapters/#{scheme}"
        rescue LoadError => e
          raise Sequel.convert_exception_class(e, AdapterNotFound)
        end

        # make sure we actually loaded the adapter
        unless klass = ADAPTER_MAP[scheme]
          raise AdapterNotFound, "Could not load #{scheme} adapter: adapter class not registered in ADAPTER_MAP"
        end
      end
      klass
    end

adapter_scheme() click to toggle source

Returns the scheme symbol for the Database class.

    # File lib/sequel/database/connecting.rb, line 43
    def self.adapter_scheme
      @scheme
    end

connect(conn_string, opts = {}) click to toggle source

Connects to a database. See Sequel.connect.

    # File lib/sequel/database/connecting.rb, line 48
    def self.connect(conn_string, opts = {})
      case conn_string
      when String
        if match = /\A(jdbc|do):/.match(conn_string)
          c = adapter_class(match[1].to_sym)
          opts = opts.merge(:orig_opts=>opts.dup)
          opts = {:uri=>conn_string}.merge(opts)
        else
          uri = URI.parse(conn_string)
          scheme = uri.scheme
          scheme = :dbi if scheme =~ /\Adbi-/
          c = adapter_class(scheme)
          uri_options = c.send(:uri_to_options, uri)
          uri.query.split('&').collect{|s| s.split('=')}.each{|k,v| uri_options[k.to_sym] = v if k && !k.empty?} unless uri.query.to_s.strip.empty?
          uri_options.to_a.each{|k,v| uri_options[k] = (defined?(URI::DEFAULT_PARSER) ? URI::DEFAULT_PARSER : URI).unescape(v) if v.is_a?(String)}
          opts = uri_options.merge(opts).merge!(:orig_opts=>opts.dup, :uri=>conn_string, :adapter=>scheme)
        end
      when Hash
        opts = conn_string.merge(opts)
        opts = opts.merge(:orig_opts=>opts.dup)
        c = adapter_class(opts[:adapter_class] || opts[:adapter] || opts['adapter'])
      else
        raise Error, "Sequel::Database.connect takes either a Hash or a String, given: #{conn_string.inspect}"
      end
      # process opts a bit
      opts = opts.inject({}) do |m, (k,v)|
        k = :user if k.to_s == 'username'
        m[k.to_sym] = v
        m
      end
      begin
        db = c.new(opts)
        db.test_connection if opts[:test] && db.send(:typecast_value_boolean, opts[:test])
        if block_given?
          return yield(db)
        end
      ensure
        if block_given?
          db.disconnect if db
          Sequel.synchronize{::Sequel::DATABASES.delete(db)}
        end
      end
      db
    end

### Public Instance Methods

adapter_scheme() click to toggle source

Returns the scheme symbol for this instance's class, which reflects which adapter is being used. In some cases, this can be the same as the `database_type` (for native adapters), in others (i.e. adapters with subadapters), it will be different.

    Sequel.connect('jdbc:postgres://...').adapter_scheme # => :jdbc

    # File lib/sequel/database/connecting.rb, line 121
    def adapter_scheme
      self.class.adapter_scheme
    end

add_servers(servers) click to toggle source

Dynamically add new servers or modify server options at runtime. Also adds new servers to the connection pool. Intended for use with master/slave or shard configurations where it is useful to add new server hosts at runtime.

servers argument should be a hash with server name symbol keys and hash or proc values. If a servers key is already in use, it's value is overridden with the value provided.

    DB.add_servers(:f=>{:host=>"hash_host_f"})

    # File lib/sequel/database/connecting.rb, line 134
    def add_servers(servers)
      if h = @opts[:servers]
        Sequel.synchronize{h.merge!(servers)}
        @pool.add_servers(servers.keys)
      end
    end

connect(server) click to toggle source

Connects to the database. This method should be overridden by descendants.

    # File lib/sequel/database/connecting.rb, line 142
    def connect(server)
      Sequel::Deprecation.deprecate('Database#connect default implementation and Sequel::NotImplemented', 'All database instance can be assumed to implement connect.')
      raise NotImplemented, "#connect should be overridden by adapters"
    end

database_type() click to toggle source

The database type for this database object, the same as the adapter scheme by default. Should be overridden in adapters (especially shared adapters) to be the correct type, so that even if two separate Database objects are using different adapters you can tell that they are using the same database type. Even better, you can tell that two Database objects that are using the same adapter are connecting to different database types (think JDBC or DataObjects).

    Sequel.connect('jdbc:postgres://...').database_type # => :postgres

    # File lib/sequel/database/connecting.rb, line 156
    def database_type
      adapter_scheme
    end

disconnect(opts = {}) click to toggle source

Disconnects all available connections from the connection pool. Any connections currently in use will not be disconnected. Options:

:servers | Should be a symbol specifing the server to disconnect from, or an array of symbols to specify multiple servers.

Example:

    DB.disconnect # All servers
    DB.disconnect(:servers=>:server1) # Single server
    DB.disconnect(:servers=>[:server1, :server2]) # Multiple servers

    # File lib/sequel/database/connecting.rb, line 170
    def disconnect(opts = {})
      pool.disconnect(opts)
    end

disconnect_connection(conn) click to toggle source

Should only be called by the connection pool code to disconnect a connection. By default, calls the close method on the connection object, since most adapters use that, but should be overwritten on other adapters.

    # File lib/sequel/database/connecting.rb, line 177
    def disconnect_connection(conn)
      conn.close
    end

each_server(&block) click to toggle source

Yield a new Database instance for every server in the connection pool. Intended for use in sharded environments where there is a need to make schema modifications (DDL queries) on each shard.

    DB.each_server{|db| db.create_table(:users){primary_key :id; String :name}}

    # File lib/sequel/database/connecting.rb, line 186
    def each_server(&block)
      raise(Error, "Database#each_server must be passed a block") unless block
      servers.each{|s| self.class.connect(server_opts(s), &block)}
    end

remove_servers(*servers) click to toggle source

Dynamically remove existing servers from the connection pool. Intended for use with master/slave or shard configurations where it is useful to remove existing server hosts at runtime.

servers should be symbols or arrays of symbols. If a nonexistent server is specified, it is ignored. If no servers have been specified for this database, no changes are made. If you attempt to remove the :default server, an error will be raised.

    DB.remove_servers(:f1, :f2)

    # File lib/sequel/database/connecting.rb, line 201
    def remove_servers(*servers)
      if h = @opts[:servers]
        servers.flatten.each{|s| Sequel.synchronize{h.delete(s)}}
        @pool.remove_servers(servers)
      end
    end

servers() click to toggle source

An array of servers/shards for this Database object.

    DB.servers # Unsharded: => [:default]
    DB.servers # Sharded:   => [:default, :server1, :server2]

    # File lib/sequel/database/connecting.rb, line 212
    def servers
      pool.servers
    end

single_threaded?() click to toggle source

Returns true if the database is using a single-threaded connection pool.

    # File lib/sequel/database/connecting.rb, line 217
    def single_threaded?
      @single_threaded
    end

synchronize(server=nil) click to toggle source

Acquires a database connection, yielding it to the passed block. This is useful if you want to make sure the same connection is used for all database queries in the block. It is also useful if you want to gain direct access to the underlying connection object if you need to do something Sequel does not natively support.

If a server option is given, acquires a connection for that specific server, instead of the :default server.

    DB.synchronize do |conn|
      ...
    end

    # File lib/sequel/database/connecting.rb, line 234
    def synchronize(server=nil)
      @pool.hold(server || :default){|conn| yield conn}
    end

test_connection(server=nil) click to toggle source

Attempts to acquire a database connection. Returns true if successful. Will probably raise an Error if unsuccessful. If a server argument is given, attempts to acquire a database connection to the given server/shard.

    # File lib/sequel/database/connecting.rb, line 249
    def test_connection(server=nil)
      synchronize(server){|conn|}
      true
    end

valid_connection?(conn) click to toggle source

Check whether the given connection is currently valid, by running a query against it. If the query fails, the connection should probably be removed from the connection pool.

    # File lib/sequel/database/connecting.rb, line 258
    def valid_connection?(conn)
      sql = valid_connection_sql
      begin
        log_connection_execute(conn, sql)
      rescue Sequel::DatabaseError, *database_error_classes
        false
      else
        true
      end
    end

## 5 - Methods that set defaults for created datasets ↑ top

This methods change the default behavior of this database's datasets.

### Constants

DatasetClass

  The default class to use for datasets

### Attributes

identifier_input_method[R]

The identifier input method to use by default for all databases (default: adapter default)

identifier_output_method[R]

The identifier output method to use by default for all databases (default: adapter default)

quote_identifiers[RW]

Whether to quote identifiers (columns and tables) by default for all databases (default: adapter default)

dataset_class[R]

The class to use for creating datasets. Should respond to new with the Database argument as the first argument, and an optional options hash.

identifier_input_method[R]

The identifier input method to use by default for this database (default: adapter default)

identifier_output_method[R]

The identifier output method to use by default for this database (default: adapter default)

### Public Class Methods

identifier_input_method=(v) click to toggle source

Change the default identifier input method to use for all databases,

    # File lib/sequel/database/dataset_defaults.rb, line 27
    def self.identifier_input_method=(v)
      @identifier_input_method = v.nil? ? false : v
    end

identifier_output_method=(v) click to toggle source

Change the default identifier output method to use for all databases,

    # File lib/sequel/database/dataset_defaults.rb, line 32
    def self.identifier_output_method=(v)
      @identifier_output_method = v.nil? ? false : v
     end

### Public Instance Methods

_default_schema() click to toggle source

REMOVE40

    # File lib/sequel/database/dataset_defaults.rb, line 48
    def _default_schema
      @default_schema
    end

dataset_class=(c) click to toggle source

If the database has any dataset modules associated with it, use a subclass of the given class that includes the modules as the dataset class.

    # File lib/sequel/database/dataset_defaults.rb, line 63
    def dataset_class=(c)
      unless @dataset_modules.empty?
        c = Class.new(c)
        @dataset_modules.each{|m| c.send(:include, m)}
      end
      @dataset_class = c
      reset_default_dataset
    end

default_schema() click to toggle source

    # File lib/sequel/database/dataset_defaults.rb, line 51
    def default_schema
      Sequel::Deprecation.deprecate('Database#default_schema', 'Use qualified tables instead')
      @default_schema
    end

default_schema=(v) click to toggle source

    # File lib/sequel/database/dataset_defaults.rb, line 55
    def default_schema=(v)
      Sequel::Deprecation.deprecate('Database#default_schema=', 'Use qualified tables instead') if v
      @default_schema = v
    end

extend_datasets(mod=nil, &block) click to toggle source

Equivalent to extending all datasets produced by the database with a module. What it actually does is use a subclass of the current dataset_class as the new dataset_class, and include the module in the subclass. Instead of a module, you can provide a block that is used to create an anonymous module.

This allows you to override any of the dataset methods even if they are defined directly on the dataset class that this Database object uses.

Examples:

    # Introspec columns for all of DB's datasets
    DB.extend_datasets(Sequel::ColumnsIntrospection)

    # Trace all SELECT queries by printing the SQL and the full backtrace
    DB.extend_datasets do
      def fetch_rows(sql)
        puts sql
        puts caller
        super
      end
    end

    # File lib/sequel/database/dataset_defaults.rb, line 94
    def extend_datasets(mod=nil, &block)
      raise(Error, "must provide either mod or block, not both") if mod && block
      mod = Module.new(&block) if block
      if @dataset_modules.empty?
       @dataset_modules = [mod]
       @dataset_class = Class.new(@dataset_class)
      else
       @dataset_modules << mod
      end
      @dataset_class.send(:include, mod)
      reset_default_dataset
    end

identifier_input_method=(v) click to toggle source

Set the method to call on identifiers going into the database:

    DB[:items] # SELECT * FROM items
    DB.identifier_input_method = :upcase
    DB[:items] # SELECT * FROM ITEMS

    # File lib/sequel/database/dataset_defaults.rb, line 112
    def identifier_input_method=(v)
      reset_default_dataset
      @identifier_input_method = v
    end

identifier_output_method=(v) click to toggle source

Set the method to call on identifiers coming from the database:

    DB[:items].first # {:id=>1, :name=>'foo'}
    DB.identifier_output_method = :upcase
    DB[:items].first # {:ID=>1, :NAME=>'foo'}

    # File lib/sequel/database/dataset_defaults.rb, line 122
    def identifier_output_method=(v)
      reset_default_dataset
      @identifier_output_method = v
    end

quote_identifiers=(v) click to toggle source

Set whether to quote identifiers (columns and tables) for this database:

    DB[:items] # SELECT * FROM items
    DB.quote_identifiers = true
    DB[:items] # SELECT * FROM "items"

    # File lib/sequel/database/dataset_defaults.rb, line 132
    def quote_identifiers=(v)
      reset_default_dataset
      @quote_identifiers = v
    end

quote_identifiers?() click to toggle source

Returns true if the database quotes identifiers.

    # File lib/sequel/database/dataset_defaults.rb, line 138
    def quote_identifiers?
      @quote_identifiers
    end

## 6 - Methods relating to logging ↑ top

This methods affect relating to the logging of executed SQL.

### Attributes

log_warn_duration[RW]

Numeric specifying the duration beyond which queries are logged at warn level instead of info level.

loggers[RW]

Array of SQL loggers to use for this database.

sql_log_level[RW]

Log level at which to log SQL queries. This is actually the method sent to the logger, so it should be the method name symbol. The default is :info, it can be set to :debug to log at DEBUG level.

### Public Instance Methods

log_exception(exception, message) click to toggle source

Log a message at error level, with information about the exception.

    # File lib/sequel/database/logging.rb, line 21
    def log_exception(exception, message)
      log_each(:error, "#{exception.class}: #{exception.message.strip if exception.message}: #{message}")
    end

log_info(message, args=nil) click to toggle source

Log a message at level info to all loggers.

    # File lib/sequel/database/logging.rb, line 26
    def log_info(message, args=nil)
      log_each(:info, args ? "#{message}; #{args.inspect}" : message)
    end

log_yield(sql, args=nil) click to toggle source

Yield to the block, logging any errors at error level to all loggers, and all other queries with the duration at warn or info level.

    # File lib/sequel/database/logging.rb, line 32
    def log_yield(sql, args=nil)
      return yield if @loggers.empty?
      sql = "#{sql}; #{args.inspect}" if args
      start = Time.now
      begin
        yield
      rescue => e
        log_exception(e, sql)
        raise
      ensure
        log_duration(Time.now - start, sql) unless e
      end
    end

logger=(logger) click to toggle source

Remove any existing loggers and just use the given logger:

    DB.logger = Logger.new($stdout)

    # File lib/sequel/database/logging.rb, line 49
    def logger=(logger)
      @loggers = Array(logger)
    end

## 7 - Miscellaneous methods ↑ top

These methods don't fit neatly into another category.

### Constants

CHECK_CONSTRAINT_SQLSTATES
DEFAULT_DATABASE_ERROR_REGEXPS

  Empty exception regexp to class map, used by default if Sequel doesn't have specific support for the database in use.

DEFAULT_STRING_COLUMN_SIZE

  The general default size for string columns for all Sequel::Database instances.

EXTENSIONS

  Hash of extension name symbols to callable objects to load the extension into the Database object (usually by extending it with a module defined in the extension).

FOREIGN_KEY_CONSTRAINT_SQLSTATES
LEADING_ZERO_RE

  Used for checking/removing leading zeroes from strings so they don't get interpreted as octal.

LEADING_ZERO_REP

  :nocov: Replacement string when replacing leading zeroes.

NOT_NULL_CONSTRAINT_SQLSTATES
SCHEMA_TYPE_CLASSES

  Mapping of schema type symbols to class or arrays of classes for that symbol.

SERIALIZATION_CONSTRAINT_SQLSTATES
UNIQUE_CONSTRAINT_SQLSTATES

### Attributes

default_string_column_size[RW]

The specific default size of string columns for this Sequel::Database, usually 255 by default.

opts[R]

The options hash for this database

timezone[W]

Set the timezone to use for this database, overridding `Sequel.database_timezone`.

### Public Class Methods

after_initialize(&block) click to toggle source

Register a hook that will be run when a new Database is instantiated. It is called with the new database handle.

    # File lib/sequel/database/misc.rb, line 40
    def self.after_initialize(&block)
      raise Error, "must provide block to after_initialize" unless block
      Sequel.synchronize do
        previous = @initialize_hook
        @initialize_hook = Proc.new do |db|
          previous.call(db)
          block.call(db)
        end
      end
    end

extension(*extensions) click to toggle source

Apply an extension to all Database objects created in the future.

    # File lib/sequel/database/misc.rb, line 52
    def self.extension(*extensions)
      after_initialize{|db| db.extension(*extensions)}
    end

new(opts = {}, &block) click to toggle source

Constructs a new instance of a database connection with the specified options hash.

Accepts the following options:

:default_string_column_size | The default size of string columns, 255 by default.
:identifier_input_method | A string method symbol to call on identifiers going into the database
:identifier_output_method | A string method symbol to call on identifiers coming from the database
:logger | A specific logger to use
:loggers | An array of loggers to use
:quote_identifiers | Whether to quote identifiers
:servers | A hash specifying a server/shard specific options, keyed by shard symbol
:single_threaded | Whether to use a single-threaded connection pool
:sql_log_level | Method to use to log SQL to a logger, :info by default.

All options given are also passed to the connection pool.

    # File lib/sequel/database/misc.rb, line 113
    def initialize(opts = {}, &block)
      @opts ||= opts
      @opts = connection_pool_default_options.merge(@opts)
      @loggers = Array(@opts[:logger]) + Array(@opts[:loggers])
      self.log_warn_duration = @opts[:log_warn_duration]
      block ||= proc{|server| connect(server)}
      @opts[:servers] = {} if @opts[:servers].is_a?(String)
      @opts[:adapter_class] = self.class

      @opts[:single_threaded] = @single_threaded = typecast_value_boolean(@opts.fetch(:single_threaded, Database.single_threaded))
      @schemas = {}
      @default_schema = @opts.fetch(:default_schema, default_schema_default)
      @default_string_column_size = @opts[:default_string_column_size] || DEFAULT_STRING_COLUMN_SIZE
      @prepared_statements = {}
      @transactions = {}
      @identifier_input_method = nil
      @identifier_output_method = nil
      @quote_identifiers = nil
      @timezone = nil
      @dataset_class = dataset_class_default
      @cache_schema = typecast_value_boolean(@opts.fetch(:cache_schema, true))
      @dataset_modules = []
      @schema_type_classes = SCHEMA_TYPE_CLASSES.dup
      self.sql_log_level = @opts[:sql_log_level] ? @opts[:sql_log_level].to_sym : :info
      @pool = ConnectionPool.get_pool(self, @opts)

      reset_identifier_mangling
      adapter_initialize

      unless typecast_value_boolean(@opts[:keep_reference]) == false
        Sequel.synchronize{::Sequel::DATABASES.push(self)}
      end
      Sequel::Database.run_after_initialize(self)
    end

register_extension(ext, mod=nil, &block) click to toggle source

Register an extension callback for Database objects. ext should be the extension name symbol, and mod should either be a Module that the database is extended with, or a callable object called with the database object. If mod is not provided, a block can be provided and is treated as the mod object.

    # File lib/sequel/database/misc.rb, line 61
    def self.register_extension(ext, mod=nil, &block)
      if mod
        raise(Error, "cannot provide both mod and block to Database.register_extension") if block
        if mod.is_a?(Module)
          block = proc{|db| db.extend(mod)}
        else
          block = mod
        end
      end
      Sequel.synchronize{EXTENSIONS[ext] = block}
    end

run_after_initialize(instance) click to toggle source

Run the after_initialize hook for the given `instance`.

    # File lib/sequel/database/misc.rb, line 74
    def self.run_after_initialize(instance)
      @initialize_hook.call(instance)
    end

### Public Instance Methods

after_commit(opts={}, &block) click to toggle source

If a transaction is not currently in process, yield to the block immediately. Otherwise, add the block to the list of blocks to call after the currently in progress transaction commits (and only if it commits). Options:

:server | The server/shard to use.

    # File lib/sequel/database/misc.rb, line 153
    def after_commit(opts={}, &block)
      raise Error, "must provide block to after_commit" unless block
      synchronize(opts[:server]) do |conn|
        if h = _trans(conn)
          raise Error, "cannot call after_commit in a prepared transaction" if h[:prepare]
          (h[:after_commit] ||= []) << block
        else
          yield
        end
      end
    end

after_rollback(opts={}, &block) click to toggle source

If a transaction is not currently in progress, ignore the block. Otherwise, add the block to the list of the blocks to call after the currently in progress transaction rolls back (and only if it rolls back). Options:

:server | The server/shard to use.

    # File lib/sequel/database/misc.rb, line 170
    def after_rollback(opts={}, &block)
      raise Error, "must provide block to after_rollback" unless block
      synchronize(opts[:server]) do |conn|
        if h = _trans(conn)
          raise Error, "cannot call after_rollback in a prepared transaction" if h[:prepare]
          (h[:after_rollback] ||= []) << block
        end
      end
    end

cast_type_literal(type) click to toggle source

Cast the given type to a literal type

    DB.cast_type_literal(Float) # double precision
    DB.cast_type_literal(:foo) # foo

    # File lib/sequel/database/misc.rb, line 184
    def cast_type_literal(type)
      type_literal(:type=>type)
    end

extension(*exts) click to toggle source

Load an extension into the receiver. In addition to requiring the extension file, this also modifies the database to work with the extension (usually extending it with a module defined in the extension file). If no related extension file exists or the extension does not have specific support for Database objects, an Error will be raised. Returns self.

    # File lib/sequel/database/misc.rb, line 193
    def extension(*exts)
      Sequel.extension(*exts)
      exts.each do |ext|
        if pr = Sequel.synchronize{EXTENSIONS[ext]}
          pr.call(self)
        else
          raise(Error, "Extension #{ext} does not have specific support handling individual databases")
        end
      end
      self
    end

from_application_timestamp(v) click to toggle source

Convert the given timestamp from the application's timezone, to the databases's timezone or the default database timezone if the database does not have a timezone.

    # File lib/sequel/database/misc.rb, line 208
    def from_application_timestamp(v)
      Sequel.convert_output_timestamp(v, timezone)
    end

in_transaction?(opts={}) click to toggle source

Return true if already in a transaction given the options, false otherwise. Respects the :server option for selecting a shard.

    # File lib/sequel/database/misc.rb, line 215
    def in_transaction?(opts={})
      synchronize(opts[:server]){|conn| !!_trans(conn)}
    end

inspect() click to toggle source

Returns a string representation of the database object including the class name and connection URI and options used when connecting (if any).

    # File lib/sequel/database/misc.rb, line 221
    def inspect
      a = []
      a << uri.inspect if uri
      if (oo = opts[:orig_opts]) && !oo.empty?
        a << oo.inspect
      end
      "#<#{self.class}: #{a.join(' ')}>"
    end

literal(v) click to toggle source

Proxy the literal call to the dataset.

    DB.literal(1) # 1
    DB.literal(:a) # a
    DB.literal('a') # 'a'

    # File lib/sequel/database/misc.rb, line 235
    def literal(v)
      schema_utility_dataset.literal(v)
    end

prepared_statement(name) click to toggle source

Synchronize access to the prepared statements cache.

    # File lib/sequel/database/misc.rb, line 240
    def prepared_statement(name)
      Sequel.synchronize{prepared_statements[name]}
    end

quote_identifier(v) click to toggle source

Proxy the quote_identifier method to the dataset, useful for quoting unqualified identifiers for use outside of datasets.

    # File lib/sequel/database/misc.rb, line 247
    def quote_identifier(v)
      schema_utility_dataset.quote_identifier(v)
    end

schema_type_class(type) click to toggle source

Return ruby class or array of classes for the given type symbol.

    # File lib/sequel/database/misc.rb, line 252
    def schema_type_class(type)
      @schema_type_classes[type]
    end

serial_primary_key_options() click to toggle source

Default serial primary key options, used by the table creation code.

    # File lib/sequel/database/misc.rb, line 258
    def serial_primary_key_options
      {:primary_key => true, :type => Integer, :auto_increment => true}
    end

set_prepared_statement(name, ps) click to toggle source

Cache the prepared statement object at the given name.

    # File lib/sequel/database/misc.rb, line 263
    def set_prepared_statement(name, ps)
      ps.prepared_sql
      Sequel.synchronize{prepared_statements[name] = ps}
    end

timezone() click to toggle source

The timezone to use for this database, defaulting to `Sequel.database_timezone`.

    # File lib/sequel/database/misc.rb, line 269
    def timezone
      @timezone || Sequel.database_timezone
    end

to_application_timestamp(v) click to toggle source

Convert the given timestamp to the application's timezone, from the databases's timezone or the default database timezone if the database does not have a timezone.

    # File lib/sequel/database/misc.rb, line 276
    def to_application_timestamp(v)
      Sequel.convert_timestamp(v, timezone)
    end

typecast_value(column_type, value) click to toggle source

Typecast the value to the given column_type. Calls typecast_value_#{column_type} if the method exists, otherwise returns the value. This method should raise Sequel::InvalidValue if assigned value is invalid.

    # File lib/sequel/database/misc.rb, line 285
    def typecast_value(column_type, value)
      return nil if value.nil?
      meth = "typecast_value_#{column_type}"
      begin
        respond_to?(meth, true) ? send(meth, value) : value
      rescue ArgumentError, TypeError => e
        raise Sequel.convert_exception_class(e, InvalidValue)
      end
    end

uri() click to toggle source

Returns the URI use to connect to the database. If a URI was not used when connecting, returns nil.

    # File lib/sequel/database/misc.rb, line 297
    def uri
      opts[:uri]
    end

url() click to toggle source

Explicit alias of uri for easier subclassing.

    # File lib/sequel/database/misc.rb, line 302
    def url
      uri
    end

## 8 - Methods related to database transactions ↑ top

Database transactions make multiple queries atomic, so that either all of the queries take effect or none of them do.

### Constants

SQL_BEGIN
SQL_COMMIT
SQL_RELEASE_SAVEPOINT
SQL_ROLLBACK
SQL_ROLLBACK_TO_SAVEPOINT
SQL_SAVEPOINT
TRANSACTION_BEGIN
TRANSACTION_COMMIT
TRANSACTION_ISOLATION_LEVELS
TRANSACTION_ROLLBACK

### Attributes

transaction_isolation_level[RW]

The default transaction isolation level for this database, used for all future transactions. For MSSQL, this should be set to something if you ever plan to use the :isolation option to Database#transaction, as on MSSQL if affects all future transactions on the same connection.

### Public Instance Methods

transaction(opts={}, &block) click to toggle source

Starts a database transaction. When a database transaction is used, either all statements are successful or none of the statements are successful. Note that MySQL MyISAM tables do not support transactions.

The following general options are respected:

:disconnect | If set to :retry, automatically sets the :retry_on option with a Sequel::DatabaseDisconnectError. This option is only present for backwards compatibility, please use the :retry_on option instead.
:isolation | The transaction isolation level to use for this transaction, should be :uncommitted, :committed, :repeatable, or :serializable, used if given and the database/adapter supports customizable transaction isolation levels.
:num_retries | The number of times to retry if the :retry_on option is used. The default is 5 times. Can be set to nil to retry indefinitely, but that is not recommended.
:prepare | A string to use as the transaction identifier for a prepared transaction (two-phase commit), if the database/adapter supports prepared transactions.
:retry_on | An exception class or array of exception classes for which to automatically retry the transaction. Can only be set if not inside an existing transaction. Note that this should not be used unless the entire transaction block is idempotent, as otherwise it can cause non-idempotent behavior to execute multiple times.
:rollback | Can the set to :reraise to reraise any Sequel::Rollback exceptions raised, or :always to always rollback even if no exceptions occur (useful for testing).
:server | The server to use for the transaction.
:savepoint | Whether to create a new savepoint for this transaction, only respected if the database/adapter supports savepoints. By default Sequel will reuse an existing transaction, so if you want to use a savepoint you must use this option.

PostgreSQL specific options:

:deferrable | (9.1+) If present, set to DEFERRABLE if true or NOT DEFERRABLE if false.
:read_only | If present, set to READ ONLY if true or READ WRITE if false.
:synchronous | if non-nil, set synchronous_commit appropriately. Valid values true, :on, false, :off, :local (9.1+), and :remote_write (9.2+).

    # File lib/sequel/database/transactions.rb, line 75
    def transaction(opts={}, &block)
      if opts[:disconnect] == :retry
        Sequel::Deprecation.deprecate('Database#transaction :disconnect=>:retry option', 'Please switch to :retry_on=>Sequel::DatabaseDisconnectError.')
        raise(Error, 'cannot specify both :disconnect=>:retry and :retry_on') if opts[:retry_on]
        return transaction(opts.merge(:retry_on=>Sequel::DatabaseDisconnectError, :disconnect=>nil), &block)
      end

      if retry_on = opts[:retry_on]
        num_retries = opts.fetch(:num_retries, 5)
        begin
          transaction(opts.merge(:retry_on=>nil, :retrying=>true), &block)
        rescue *retry_on
          if num_retries
            num_retries -= 1
            retry if num_retries >= 0
          else
            retry
          end
          raise
        end
      else
        synchronize(opts[:server]) do |conn|
          if already_in_transaction?(conn, opts)
            if opts[:retrying]
              raise Sequel::Error, "cannot set :disconnect=>:retry or :retry_on options if you are already inside a transaction"
            end
            return yield(conn)
          end
          _transaction(conn, opts, &block)
        end
      end
    end

## 9 - Methods that describe what the database supports ↑ top

These methods all return booleans, with most describing whether or not the database supprots a given feature.

### Public Instance Methods

global_index_namespace?() click to toggle source

Whether the database uses a global namespace for the index. If false, the indexes are going to be namespaced per table.

    # File lib/sequel/database/features.rb, line 11
    def global_index_namespace?
      true
    end

supports_create_table_if_not_exists?() click to toggle source

Whether the database supports CREATE TABLE IF NOT EXISTS syntax, false by default.

    # File lib/sequel/database/features.rb, line 17
    def supports_create_table_if_not_exists?
      false
    end

supports_deferrable_constraints?() click to toggle source

Whether the database supports deferrable constraints, false by default as few databases do.

    # File lib/sequel/database/features.rb, line 23
    def supports_deferrable_constraints?
      false
    end

supports_deferrable_foreign_key_constraints?() click to toggle source

Whether the database supports deferrable foreign key constraints, false by default as few databases do.

    # File lib/sequel/database/features.rb, line 29
    def supports_deferrable_foreign_key_constraints?
      supports_deferrable_constraints?
    end

supports_drop_table_if_exists?() click to toggle source

Whether the database supports DROP TABLE IF EXISTS syntax, default is the same as supports_create_table_if_not_exists?.

    # File lib/sequel/database/features.rb, line 35
    def supports_drop_table_if_exists?
      supports_create_table_if_not_exists?
    end

supports_foreign_key_parsing?() click to toggle source

Whether the database supports Database#foreign_key_list for parsing foreign keys.

    # File lib/sequel/database/features.rb, line 41
    def supports_foreign_key_parsing?
      [:access, :mssql, :mysql, :postgres, :sqlite].include?(database_type)
    end

supports_index_parsing?() click to toggle source

Whether the database supports Database#indexes for parsing indexes.

    # File lib/sequel/database/features.rb, line 46
    def supports_index_parsing?
      [:access, :cubrid, :db2, :mssql, :mysql, :postgres, :sqlite].include?(database_type) || adapter_scheme == :jdbc
    end

supports_prepared_transactions?() click to toggle source

Whether the database and adapter support prepared transactions (two-phase commit), false by default.

    # File lib/sequel/database/features.rb, line 52
    def supports_prepared_transactions?
      false
    end

supports_savepoints?() click to toggle source

Whether the database and adapter support savepoints, false by default.

    # File lib/sequel/database/features.rb, line 57
    def supports_savepoints?
      false
    end

supports_savepoints_in_prepared_transactions?() click to toggle source

Whether the database and adapter support savepoints inside prepared transactions (two-phase commit), default is false.

    # File lib/sequel/database/features.rb, line 63
    def supports_savepoints_in_prepared_transactions?
      supports_prepared_transactions? && supports_savepoints?
    end

supports_schema_parsing?() click to toggle source

Whether the database supports schema parsing via Database#schema.

    # File lib/sequel/database/features.rb, line 68
    def supports_schema_parsing?
      respond_to?(:schema_parse_table, true)
    end

supports_table_listing?() click to toggle source

Whether the database supports Database#tables for getting list of tables.

    # File lib/sequel/database/features.rb, line 73
    def supports_table_listing?
      [:access, :cubrid, :db2, :firebird, :mssql, :mysql, :oracle, :postgres, :sqlite].include?(database_type) || adapter_scheme == :jdbc
    end

supports_transaction_isolation_levels?() click to toggle source

Whether the database and adapter support transaction isolation levels, false by default.

    # File lib/sequel/database/features.rb, line 83
    def supports_transaction_isolation_levels?
      false
    end

supports_transactional_ddl?() click to toggle source

Whether DDL statements work correctly in transactions, false by default.

    # File lib/sequel/database/features.rb, line 88
    def supports_transactional_ddl?
      false
    end

supports_view_listing?() click to toggle source

Whether the database supports Database#views for getting list of views.

    # File lib/sequel/database/features.rb, line 78
    def supports_view_listing?
      supports_table_listing?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.