The LooserTypecasting extension changes the float and integer typecasting to use the looser .to_f and .to_i instead of the more strict Kernel.Float and Kernel.Integer. To use it, you should extend the database with the Sequel::LooserTypecasting module after loading the extension:
Sequel.extension :looser_typecasting DB.extend(Sequel::LooserTypecasting)
The pagination extension adds the Sequel::Dataset#paginate and each_page methods, which return paginated (limited and offset) datasets with some helpful methods that make creating a paginated display easier.
The pretty_table extension adds Sequel::Dataset#print and the Sequel::PrettyTable class for creating nice-looking plain-text tables.
The query extension adds Sequel::Dataset#query which allows a different way to construct queries instead of the usual method chaining.
The schema_dumper extension supports dumping tables and indexes in a Sequel::Migration format, so they can be restored on another database (which can be the same type or a different type than the current database). The main interface is through Sequel::Database#dump_schema_migration.
The sql_expr extension adds the sql_expr method to every object, which returns an object that works nicely with Sequel's DSL. This is best shown by example:
1.sql_expr < :a # 1 < a false.sql_expr & :a # FALSE AND a true.sql_expr | :a # TRUE OR a ~nil.sql_expr # NOT NULL "a".sql_expr + "b" # 'a' || 'b'
The thread_local_timezones extension allows you to set a per-thread timezone that will override the default global timezone while the thread is executing. The main use case is for web applications that execute each request in its own thread, and want to set the timezones based on the request. The most common example is having the database always store time in UTC, but have the application deal with the timezone of the current user. That can be done with:
Sequel.database_timezone = :utc # In each thread: Sequel.thread_application_timezone = current_user.timezone
This extension is designed to work with the named_timezones extension.
This extension adds the thread_application_timezone=, thread_database_timezone=, and thread_typecast_timezone= methods to the Sequel module. It overrides the application_timezone, database_timezone, and typecast_timezone methods to check the related thread local timezone first, and use it if present. If the related thread local timezone is not present, it falls back to the default global timezone.
There is one special case of note. If you have a default global timezone and you want to have a nil thread local timezone, you have to set the thread local value to :nil instead of nil:
Sequel.application_timezone = :utc Sequel.thread_application_timezone = nil Sequel.application_timezone # => :utc Sequel.thread_application_timezone = :nil Sequel.application_timezone # => nil
This adds a Sequel::Dataset#to_dot method. The to_dot method returns a string that can be processed by graphviz's dot program in order to get a visualization of the dataset. Basically, it shows a version of the dataset's abstract syntax tree.
The columns_introspection extension attempts to introspect the selected columns for a dataset before issuing a query. If it thinks it can guess correctly at the columns the query will use, it will return the columns without issuing a database query. This method is not fool-proof, it's possible that some databases will use column names that Sequel does not expect.
To enable this for a single dataset, extend the dataset with Sequel::ColumnIntrospection. To enable this for all datasets, run:
Sequel::Dataset.introspect_all_columns
Classes and Modules
- Sequel::ColumnsIntrospection
- Sequel::LooserTypecasting
- Sequel::NamedTimezones
- Sequel::Plugins
- Sequel::PrettyTable
- Sequel::SQL
- Sequel::Schema
- Sequel::ThreadLocalTimezones
- Sequel::Database
- Sequel::Dataset
- Sequel::IntegerMigrator
- Sequel::Migration
- Sequel::MigrationAlterTableReverser
- Sequel::MigrationDSL
- Sequel::MigrationReverser
- Sequel::Migrator
- Sequel::SimpleMigration
- Sequel::TimestampMigrator
- Sequel::ToDot
Public Class methods
The preferred method for writing Sequel migrations, using a DSL:
Sequel.migration do
up do
create_table(:artists) do
primary_key :id
String :name
end
end
down do
drop_table(:artists)
end
end
Designed to be used with the Migrator class, part of the migration extension.
# File lib/sequel/extensions/migration.rb, line 241 def self.migration(&block) MigrationDSL.create(&block) end