Sequel::Model Plugins for v5.40.0
Sequel::Model has a standardized and very flexible plugin architecture, see the RDoc. Here is a list of plugins that members of the Sequel community have developed:
Plugins that ship with Sequel
- Associations:
- association_dependencies: Allows easy deleting, destroying, or nullifying associated objects when destroying a model object.
- association_lazy_eager_option: Support :eager option when calling association method, for per-call eager loading when association is not cached.
- association_multi_add_remove: Allows adding/removing multiple associated objects in a single method call.
- association_pks: Adds the association_pks and association_pks= to *_to_many associations.
- association_proxies: Changes the *_to_many association method to return a proxy instead of an array of objects.
- dataset_associations: Adds association methods to datasets that return datasets of associated objects.
- delay_add_association: Delay add_association calls on new objects until after after the object is saved.
- eager_each: Makes each on an eagerly loaded dataset do eager loading.
- eager_graph_eager: Allows chaining eager loads to associations loaded by eager_graph.
- forbid_lazy_load: Forbids lazy loading of associations in cases where they could cause N+1 query issues.
- many_through_many: Allows you to create an association through multiple join tables.
- nested_attributes: Allows you to modified associated objects directly through a model object, similar to ActiveRecord's Nested Attributes.
- pg_array_associations: Adds associations types to handle the case where foreign keys are stored in a PostgreSQL array in one of the tables.
- rcte_tree: Supports retrieving all ancestors and descendants for tree structured data using recursive common table expressions.
- tactical_eager_loading: Allows you to eagerly load an association for all objects retreived from the same dataset when calling the association method on any of the objects in the dataset.
- tree: Allows you to treat model objects as being part of a tree, finding ancestors, descendants, siblings, and tree roots.
- validate_associated: Supports validating associated objects at the same time as the current object.
- Attributes:
- accessed_columns: Records which columns have been accessed for a given model instance.
- blacklist_security: Adds blacklist-based model mass-assignment protection.
- boolean_readers: Adds attribute? methods for all boolean columns.
- column_conflicts: Automatically handles column names that conflict with Ruby/Sequel method names.
- dirty: Allows you get get initial values of columns after changing the values.
- defaults_setter: Get default values for new models before saving.
- force_encoding: Forces the all model column string values to a given encoding.
- input_transformer: Automatically transform input to model column setters.
- lazy_attributes: Allows you to set some attributes that should not be loaded by default, but only loaded when an object requests them.
- modification_detection: Automatically detect in-place changes to column values.
- split_values: Splits noncolumn entries from values hash into separate hash.
- string_stripper: Strips strings assigned to model attributes.
- uuid: Automatically sets UUID attribute when creating model objects.
- whitelist_security: Adds whitelist-based model mass-assignment protection.
- Caching:
- caching: Supports caching primary key lookups of model objects to any object that supports the Ruby-Memcache API.
- static_cache: Caches all model instances, improving performance for static models.
- static_cache_cache: Support caching rows for static_cache models to a file to avoid database queries during model initialization.
- Hooks:
- after_initialize: Adds an after_initialize hook to model objects, called for both new objects and those loaded from the database.
- hook_class_methods: Adds backwards compatiblity for the legacy class-level hook methods (e.g. before_save :do_something).
- instance_hooks: Allows you to add hooks to specific model instances.
- Inheritance:
- class_table_inheritance: Supports inheritance in the database by using a single database table for each class in a class hierarchy.
- single_table_inheritance: Supports inheritance in the database by using a single table for all classes in a class hierarchy.
- Prepared Statements:
- prepared_statements: Makes models use prepared statements for deletes, inserts, updates, and lookups by primary key.
- prepared_statements_safe: Makes use of prepared_statements plugin more safe by setting explicit defaults for model columns when inserting and saving whole rows instead of changed columns.
- Saving:
- columns_updated: Makes columns hash used for updates available in after_update and after_save hooks.
- insert_conflict: Allows handling unique constraint conflicts when saving new model instances on PostgreSQL 9.5+ and SQLite 3.24.0+.
- instance_filters: Allows you to add per instance filters that are used when updating or destroying the instance.
- mssql_optimistic_locking: Uses a timestamp/rowversion column on Microsoft SQL Server to prevent concurrent updates overwriting changes.
- optimistic_locking: Adds a database-independent locking mechanism to models to prevent concurrent updates overwriting changes.
- sharding: Additional model support for Sequel's sharding support.
- skip_create_refresh: Allows you to skip the refresh when saving new model objects.
- skip_saving_columns: Allows for marking columns to skip when saving model objects, and skips the saving of generated columns by default.
- timestamps: Creates hooks for automatically setting create and update timestamps.
- touch: Allows easily updating timestamps via Model#touch, as well as touching associations when model instances are updated or destroyed.
- unlimited_update: Works around MySQL warnings when using replication due to LIMIT clause use when updating model instances.
- update_or_create: Adds helper methods for updating an object if it exists, or creating such an object if it does not.
- update_primary_key: Allows you to safely update the primary key of a model object.
- update_refresh: Refreshes a model object when updating it.
- Selection:
- column_select: Selects explicitly qualified columns (table.column1, table.column2, ...) instead of just * for model datasets.
- insert_returning_select: Automatically sets RETURNING clause for INSERT queries for models that use an explicit column selection.
- table_select: Selects table.* instead of just * for model datasets.
- Serialization:
- composition: Supports defining getters/setters for objects with data backed by the model's columns.
- csv_serializer: Allows you to serialize/deserialize model objects to/from CSV.
- json_serializer: Allows you to serialize/deserialize model objects to/from JSON.
- serialization: Supports serializing column values and storing them as either marshal, yaml, or json in the database.
- serialization_modification_detection: Allows you to detect changes to serialized columns.
- xml_serializer: Allows you to serialize/deserialize model objects to/from XML.
- Subsets:
- boolean_subsets: Automatically creates a subset method for each boolean column.
- def_dataset_method: Adds Model.def_dataset_method and Model.subset for backwards compatibility.
- inverted_subsets: Creates an additional method for each subset, that inverts the subset's conditions.
- subset_conditions: Creates an additional method for each subset, returning the filter conditions used for the subset.
- Validations:
- auto_validations: Automatically add presence/not_null, max length, type, and unique validations based on the model's schema.
- constraint_validations: Setup automatic validations for constraints added via the constraint_validations extension.
- empty_failure_backtraces: Uses empty backtraces for ValidationFailed and HookFailed exceptions, for much better performance on JRuby.
- error_splitter: Splits multi-column errors entries into separate errors, one per column.
- pg_auto_constraint_validations: Automatically convert constraint violations during INSERT/UPDATE on PostgreSQL to validation failures.
- throw_failures: Throws ValidationFailed and HookFailed exceptions instead of raising them, if a matching catch block is used.
- validation_class_methods: Adds backwards compatibility for the legacy class-level validation methods (e.g. validates_presence_of :column).
- validation_contexts: Allow specifying a context to use during validations.
- validation_helpers: The preferred default validations plugin, which uses instance-level methods.
- Other:
- active_model: Makes Sequel::Model objects compliant to the ActiveModel::Lint specs, so they should work correctly in Rails 3+.
- finder: Adds Model.finder and Model.prepared_finder methods for defining optimized lookup methods.
- list: Allows you to treat model objects as being part of a list, so you can move them up/down and get next/previous entries.
- pg_row: Allows Sequel::Model classes to implement PostgreSQL row-valued/composite types.
- singular_table_names: Makes Sequel default to not pluralizing table names.
- subclasses: Allows easy access all model subclasses and descendent classes, without using ObjectSpace.
- typecast_on_load: Fixes bad database typecasting when loading model objects.
External Plugins
- forme: HTML forms library for ruby that integrates with Sequel::Model for easy form creation.
- sequel-active_record: Provides ActiveRecord compatibility to ease transitions to Sequel.
- sequel_bulk_attributes: Provides bulk assignment functionality for one_to_many associations.
- sequel-bit_fields: Allows treating an integer column as a bitfield of many boolean settings.
- sequel-combine: Provides functionality of composing with childrens, parents or any object where exists any relationship. Now it is possible in one query.
- sequel_container: Contained documents (i.e. attachments) for models.
- sequel_crushyform: Builds forms for you
- sequel-elasticsearch: Sync Sequel models to Elasticsearch.
- sequel-enum_values: Provides
enum_values(field_name)
method for model class and optional optional instance predicate methods likecreated?
. - sequel-hash_id: Obscure your primary keys with a hashid.
- sequel_mappable: Provides geocoding functionality to model and dataset.
- sequel_nested_set: Nested set implementation, ported from the Awesome Nested Set Active Record plugin.
- sequel-nonsequential_id: Automatically generate non-sequential (pseudo-random) IDs for Sequel Models.
- sequel_notnaughty: Port of the NotNaughty validation framework.
- sequel_paperclip: Provides attachment functionality for models, including post processing (thumbnail generation, etc.).
- sequel-pg_advisory_lock: Allows you to use PostgreSQL advisory locks for application-level mutexes.
- sequel_pretty_print: Adds Ruby PrettyPrint support to models (works in Pry console).
- sequel_polymorphic: Lets you easily create polymorphic associations.
- sequel_proc_error_handling: Lets you add procs that automatically rescue and fix model errors.
- sequel_secure_password: Adds bcrypt authentication and password hashing to models.
- sequel_sexy_validations: Provides sexy validations (like those in rails 3) for models.
- sequel_simple_callbacks: Enables ActiveRecord-compatible class-level before and after filter declarations for models with support for conditional execution.
- sequel_sluggable: Easy slug behaviour for any model.
- sequel-table_inheritance: Combines the functionality of the single table inheritance and class table inheritance plugins.
- sequel_taggable: Allows easily adding tags to any model.
- sequel-through: Adds support for :through associations between models.
- sequel_validation_helpers_block: Allows easy determination of which validation rules apply to a given column, at the expense of increased verbosity.
Sequel Extensions
Extensions are modifications or additions to Sequel that affect either Sequel::Database objects (database extensions), Sequel::Dataset objects (dataset extensions), or the general ruby environment (global extensions).
Database extensions that ship with Sequel
Database extensions can be loaded into a single Sequel::Database object via Sequel::Database#extension, or to all databases by using Sequel::Database.extension.
- arbitrary_servers: Adds ability to connection to arbitrary servers (instead of just preconfigured ones) in the sharding support.
- caller_logging: Include caller information when logging queries.
- connection_expiration: Automatically removes connections from the pool after they have been open longer than a timeout.
- connection_validator: Automatically validates connections on pool checkout and handles disconnections transparently.
- constant_sql_override: Override generated SQL for Sequel constants with configurable strings.
- constraint_validations: Creates database constraints when creating/altering tables, with metadata for automatic model validations via the constraint_validations plugin.
- error_sql: Makes DatabaseError#sql return the SQL query that caused the underlying exception.
- identifier_mangling: Support modification for the default identifier mangling for the database.
- index_caching: Speeds up loading index information by saving/loading database index metadata to a file.
- integer64: Treats the Integer class as a 64-bit integer instead of a 32-bit integer when used as a generic database type.
- looser_typecasting: Uses .to_f and .to_i instead of Kernel.Float and Kernel.Integer when typecasting floats and integers.
- pg_array: Adds support for PostgreSQL arrays.
- pg_enum: Adds support for PostgreSQL enums.
- pg_extended_date_support: Adds support for PostgreSQL infinite and BC date/timestamp support.
- pg_hstore: Adds support for the PostgreSQL hstore type.
- pg_inet: Adds support for the PostgreSQL inet and cidr types.
- pg_interval: Adds support for the PostgreSQL interval type.
- pg_json: Adds support for the PostgreSQL json type.
- pg_loose_count: Adds Database#loose_count for fast approximate counts of whole tables on PostgreSQL.
- pg_range: Adds support for PostgreSQL range types.
- pg_row: Adds support for PostgreSQL row-valued/composite types.
- pg_static_cache_updater: Listens for changes to underlying tables in order to automatically update models using the static_cache plugin.
- pg_timestamptz: Uses timestamptz (timestamp with time zone) as the generic timestamp type used for Time and DateTime classes.
- run_transaction_hooks: Support running after_commit and after_rollback transaction hooks before transaction commit/rollback, designed for transactional testing.
- schema_caching: Speeds up loading a large number of models by caching database schema and loading it from a file.
- schema_dumper: Adds Database#dump_schema_migration and related methods for dumping the schema of the database as a migration that can be restored on other databases.
- server_block: Adds Database#with_server method that makes access inside the passed block use the specified shard by default.
- server_logging: Include server/shard information when logging queries.
Dataset extensions that ship with Sequel
Dataset extensions can be loaded into a single Sequel::Database object via Sequel::Dataset#extension, or to all datasets for a given database via Sequel::Database#extension, or all datasets for all databases by using Sequel::Database.extension.
- any_not_empty: Make Dataset#any? without block mean !empty?.
- auto_literal_strings: Automatically treats string arguments passed to filter methods as literal SQL.
- columns_introspection: Attemps to skip database queries by introspecting the selected columns if possible.
- current_datetime_timestamp: Creates current Time/DateTime objects that are literalized as CURRENT_TIMESTAMP.
- dataset_source_alias: Automatically aliases datasets to their source instead of using t1, t2, etc.
- date_arithmetic: Allows for database-independent date calculations (adding/subtracting an interval to/from a date/timestamp).
- duplicate_columns_handler: Allows you to raise or warn if the dataset returns multiple columns with the same name when returning the results.
- empty_array_consider_nulls: Makes Sequel's handling of IN/NOT IN with an empty array use a NULL expression for NULL column values.
- exclude_or_null: Add Dataset#exclude_or_null for only including rows where condition is false or NULL.
- graph_each: Makes Dataset#each split returned results by table when using Dataset#graph.
- implicit_subquery: Makes dataset methods that return datasets with modified SQL use a subquery implicitly if the current dataset uses raw SQL.
- null_dataset: Adds Dataset#nullify to get a dataset that will never issue a query.
- mssql_emulate_lateral_with_apply: Emulates LATERAL queries using CROSS/OUTER APPLY on Microsoft SQL Server.
- pagination: Adds Dataset#paginate for easier pagination of datasets.
- pretty_table: Adds Dataset#print for printing a dataset as a simple plain-text table.
- query: Adds Dataset#query for a different interface to creating queries that doesn't use method chaining.
- round_timestamps: Automatically round timestamp values to database supported precision before literalizing them.
- select_remove: Adds Dataset#select_remove to remove selected columns from a dataset.
- sequel_4_dataset_methods: Adds #and, #exclude_where, #interval, and #range dataset methods.
- split_array_nil: Splits nils out of IN/NOT IN arrays into separate OR IS NULL or AND IS NOT NULL clauses.
- sql_comments: Adds Dataset#comment method, for setting an SQL comment in the queries created by the dataset.
- string_agg: Adds generic database support for aggregate string concatentation.
- synchronize_sql: Checks out a connection while generating SQL strings, improving performance in some cases.
- to_dot: Adds Dataset#to_dot method, which returns a string suitable for processing by graphviz's dot program to get a visualization of the dataset's abstract syntax tree.
Global extensions that ship with Sequel
Global extensions can affect other parts of Sequel or the general ruby environment, and are loaded with Sequel.extension.
- blank: Adds blank? instance methods to all objects.
- core_extensions: Extends the Array, Hash, String, and Symbol classes with methods that return Sequel expression objects.
- core_refinements: Adds refinement versions of Sequel's core extensions.
- eval_inspect: Makes inspect on Sequel's expression objects attempt to return a string suitable for eval.
- escaped_like: Support creation of LIKE expressions with placeholders in the pattern without access to a dataset.
- datetime_parse_to_time: Uses DateTime.parse.to_time to parse timestamp strings without offset information where such timestamps are assumed to be in UTC.
- fiber_concurrency: Uses Fiber.current instead of Thread.current as the key for checking out connections.
- inflector: Adds instance-level inflection methods to String.
- migration: Adds Migration and Migrator classes for easily migrating the database schema forward or reverting to a previous version.
- named_timezones: Allows you to use named timezones instead of just :local and :utc (requires TZInfo).
- pg_array_ops: Adds DSL support for calling PostgreSQL array operators and functions.
- pg_hstore_ops: Adds DSL support for calling PostgreSQL hstore operators and functions.
- pg_inet_ops: Adds DSL support for calling PostgreSQL inet/cidr operators and functions.
- pg_json_ops: Adds DSL support for calling PostgreSQL json operators and functions.
- pg_range_ops: Adds DSL support for calling PostgreSQL range operators and functions.
- pg_row_ops: Adds DSL support for dealing with PostgreSQL row-valued/composite types.
- s: Adds Sequel::S module with #S private method for easily calling Sequel.expr, including use as a refinement.
- sql_expr: Adds sql_expr method to all objects, allowing easy use of Sequel's DSL.
- string_date_time: Adds instance methods to String for converting the string into a Date/Time/DateTime.
- symbol_aref: Extends Symbol#[] to create a qualified identifier if given a symbol, identifier, or qualified identifier.
- symbol_aref_refinement: Adds refinement version of symbol_aref extension.
- symbol_as: Adds Symbol#as to create aliased expressions.
- symbol_as_refinement: Adds refinement version of symbol_as extension.
- thread_local_timezones: Allows for per-thread overrides of the global timezone settings.
- virtual_row_method_block: Supports passing blocks to virtual row method for terser SQL function creation.
External Extensions
- annotate-sequel: Generates model annotations for Sequel models.
- fixture_dependencies: YAML fixture loader that handles dependencies/associated objects, respecting foreign key constraints.
- i18n_backend_sequel: Allows Sequel to be a backend for i18n translations.
- miguel: Allows management of database schemas, including auto generation/application of migrations.
- rails_sequel: Rails 2 plugin that allows you to use Sequel instead of ActiveRecord.
- refile-sequel: Provides an extension for using Refile with Sequel.
- rspec_sequel_matchers: RSpec matchers for Sequel validations, associations, and columns.
- sequel-activerecord_connection: Allows Sequel to use ActiveRecord's connection for database interaction.
- sequel-annotate: Generates model annotations for Sequel models, including constraint and trigger information on PostgreSQL.
- sequel_extjs: Generates JSON from datasets that is consumable by the ExtJS JsonStore.
- sequel-location: Easy setup and syntax for doing geolocation search on PostgreSQL.
- sequel_pg: Faster SELECTs when using Sequel with pg.
- sequel-pg_advisory_locking: Adds PostreSQL advisory locking support.
- sequel-pg-comment: Document your schema by setting comments on all your PgSQL objects.
- sequel_plus: Collection of sequel extensions.
- sequel_postgresql_triggers: Database enforced timestamps, immutable columns, and counter/sum caches.
- sequel-rails: Rails 3 plugin that allows you to use Sequel instead of ActiveRecord.
- sequel_rails3: Another Rails 3 plugin that allows you to use Sequel instead of ActiveRecord.
- sequel-force-hooks: Have after_commit/after_rollback hooks apply to current savepoint instead of transaction.
- sequel-seed: A Sequel extension to make seeds/fixtures manageable like migrations.
- sequel_vectorized: Allows Sequel::Dataset to be exported as an Hash of Arrays and NArrays.
External Adapters
Adapters allow Sequel to communicate with databases. Sequel ships with many adapters, but here are links to external adapters:
- fusiontables: Fusion Tables adapter using ft driver
- hive: Hadoop Hive adapter using rbhive driver
- impala: Impala adapter, including jdbc/hive2 adapter
- jdbc-crate: JDBC subadapter for Crate database
- jdbc-hxtt: JDBC subadapter for MS Access databases
- openedge: ODBC and JDBC subadapters for OpenEdge database
- vertica: Vertica adapter using vertica driver
Submitting Your Plugin/Extension/Adapter
If you have created a Sequel plugin/extension/adapter and would like to list it here, please submit a request to code AT jeremyevans DOT net, or send a pull request via github.