source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/skip_saving_columns.rb | Ruby | mit | 5,086 | master | 3,654 | # frozen-string-literal: true
module Sequel
module Plugins
# The skip_saving_columms plugin allows skipping specific columns when
# saving. By default, it skips columns that the database schema
# indicates are generated columns:
#
# # Assume id column, name column, and id2 generated column
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/update_or_create.rb | Ruby | mit | 5,086 | master | 2,591 | # frozen-string-literal: true
module Sequel
module Plugins
# The update_or_create plugin adds methods that make it easier
# to deal with objects which may or may not yet exist in the database.
# The first method is update_or_create, which updates an object if it
# exists in the database, or creates t... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/association_dependencies.rb | Ruby | mit | 5,086 | master | 5,249 | # frozen-string-literal: true
module Sequel
module Plugins
# The association_dependencies plugin allows you do easily set up before and/or after destroy hooks
# for destroying, deleting, or nullifying associated model objects. The following
# association types support the following dependency actions:
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/modification_detection.rb | Ruby | mit | 5,086 | master | 3,241 | # frozen-string-literal: true
module Sequel
module Plugins
# This plugin automatically detects in-place modifications to
# columns as well as direct modifications of the values hash.
#
# class User < Sequel::Model
# plugin :modification_detection
# end
# user = User[1]
# u... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/pg_auto_constraint_validations.rb | Ruby | mit | 5,086 | master | 16,030 | # frozen-string-literal: true
module Sequel
module Plugins
# The pg_auto_constraint_validations plugin automatically converts some constraint
# violation exceptions that are raised by INSERT/UPDATE queries into validation
# failures. This can allow for using the same error handling code for both
# r... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/subclasses.rb | Ruby | mit | 5,086 | master | 3,152 | # frozen-string-literal: true
module Sequel
module Plugins
# The subclasses plugin keeps track of all subclasses of the
# current model class. Direct subclasses are available via the
# subclasses method, and all descendent classes are available via the
# descendants method:
#
# c = Class.n... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/caching.rb | Ruby | mit | 5,086 | master | 5,752 | # frozen-string-literal: true
module Sequel
module Plugins
# Sequel's built-in caching plugin supports caching to any object that
# implements the Ruby-Memcache API (or memcached API with the :ignore_exceptions
# option):
#
# cache_store.set(key, obj, time) # Associate the obj with the given k... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/throw_failures.rb | Ruby | mit | 5,086 | master | 3,774 | # frozen-string-literal: true
module Sequel
module Plugins
# The throw_failures plugin throws HookFailed and ValidationFailed exceptions instead
# of raising them. If there is no matching catch block, the UncaughtThrowError will be rescued
# and the HookFailed or ValidationFailed exception will be raise... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/single_statement_dataset_destroy.rb | Ruby | mit | 5,086 | master | 1,786 | # frozen-string-literal: true
module Sequel
module Plugins
# The single_statement_dataset_destroy plugin makes the
# model dataset.destroy method delete all rows in a
# single DELETE statement. It runs all before_destroy
# hooks before the DELETE, and all after_destroy hooks
# after the delete.
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/hook_class_methods.rb | Ruby | mit | 5,086 | master | 3,974 | # frozen-string-literal: true
module Sequel
module Plugins
# Sequel's built-in hook_class_methods plugin is designed for backwards
# compatibility. Its use is not encouraged, it is recommended to use
# instance methods and super instead of this plugin. This plugin allows
# calling class methods wit... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/string_stripper.rb | Ruby | mit | 5,086 | master | 1,907 | # frozen-string-literal: true
module Sequel
module Plugins
# StringStripper is a plugin that strips all input strings
# when assigning to the model's values. Example:
#
# album = Album.new(name: ' A ')
# album.name # => 'A'
#
# SQL::Blob instances and all non-strings are not modified ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/static_cache_cache.rb | Ruby | mit | 5,086 | master | 3,462 | # frozen-string-literal: true
module Sequel
module Plugins
# The static_cache_cache plugin allows for caching the row content for the current
# class and subclasses that use the static_cache or subset_static_cache plugins.
# Using this plugin can avoid the need to query the database every time loading
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/detect_unnecessary_association_options.rb | Ruby | mit | 5,086 | master | 7,776 | # frozen-string-literal: true
module Sequel
module Plugins
# The detect_unnecessary_association_options plugin can detect unnecessary
# association options, and either warn or raise if they are detected.
# This allows you to find and remove the unnecessary options.
# Association options are considere... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/validation_helpers_generic_type_messages.rb | Ruby | mit | 5,086 | master | 2,709 | # frozen-string-literal: true
require_relative 'validation_helpers'
module Sequel
module Plugins
# The validation_helpers_generic_type_messages plugin overrides the default
# type validation failure messages in the validation_helpers plugin to be
# more generic and understandable by the average user, in... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/after_initialize.rb | Ruby | mit | 5,086 | master | 1,056 | # frozen-string-literal: true
module Sequel
module Plugins
# Adds an after_initialize hook to models, called after initializing
# both new objects and ones loaded from the database.
#
# Usage:
#
# # Make all model subclasses support the after_initialize hook
# Sequel::Model.plugin :af... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/empty_failure_backtraces.rb | Ruby | mit | 5,086 | master | 1,289 | # frozen-string-literal: true
module Sequel
module Plugins
# The empty_failure_backtraces plugin uses empty backtraces when raising HookFailed and ValidationFailed
# exceptions. This can be significantly faster, and if you are using these exceptions for
# flow control, you do not need the backtraces. T... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/dataset_associations.rb | Ruby | mit | 5,086 | master | 7,854 | # frozen-string-literal: true
module Sequel
module Plugins
# DatasetAssociations allows you to easily use your model associations
# via datasets. For each association you define, it creates a dataset
# method for that association that returns a dataset of all objects
# that are associated to objects... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/inspect_pk.rb | Ruby | mit | 5,086 | master | 1,226 | # frozen-string-literal: true
module Sequel
module Plugins
# The inspect_pk plugin includes the pk right next to the
# model name in inspect, allowing for easily copying and
# pasting to retrieve a copy of the object:
#
# Album.with_pk(1).inspect
# # default: #<Album @values={...}... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/mssql_optimistic_locking.rb | Ruby | mit | 5,086 | master | 2,300 | # frozen-string-literal: true
module Sequel
module Plugins
# This plugin implements optimistic locking mechanism on Microsoft SQL Server
# using a timestamp/rowversion column to ensure that concurrent updates are
# detected and previous changes are not automatically overridden. This is
# best impleme... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/subset_conditions.rb | Ruby | mit | 5,086 | master | 4,880 | # frozen-string-literal: true
module Sequel
module Plugins
# The subset_conditions plugin creates an additional *_conditions method
# for every `subset`, `where`, and `exclude` method call in a dataset_module
# block. This method returns the filter conditions, which can be useful if
# you want to use... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/association_lazy_eager_option.rb | Ruby | mit | 5,086 | master | 2,386 | # frozen-string-literal: true
module Sequel
module Plugins
# The association_lazy_eager_option plugin supports passing
# an +:eager+ option to an association method. If the related
# association is already cached, the cached version will be
# returned. If the association is not already cached, it w... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/update_refresh.rb | Ruby | mit | 5,086 | master | 2,891 | # frozen-string-literal: true
module Sequel
module Plugins
# The update_refresh plugin makes the model class refresh
# the object after updating. By default, Sequel only
# refreshes automatically after inserting new rows, not
# after updating. However, if you are using triggers
# to modify the ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/blacklist_security.rb | Ruby | mit | 5,086 | master | 4,305 | # frozen-string-literal: true
module Sequel
module Plugins
# The blacklist_security plugin contains blacklist-based support for
# mass assignment, specifying which columns to not allow mass assignment for,
# implicitly allowing mass assignment for columns not listed. This is only
# for backwards com... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/pg_eager_any_typed_array.rb | Ruby | mit | 5,086 | master | 3,484 | # frozen-string-literal: true
module Sequel
module Plugins
# The pg_eager_any_typed_array plugin automatically converts
# the predicate expressions used for eager loading from:
#
# table.column IN (value_list)
#
# to:
#
# table.column = ANY(array_expr::type[])
#
# This mak... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/sharding.rb | Ruby | mit | 5,086 | master | 4,088 | # frozen-string-literal: true
module Sequel
module Plugins
# The sharding plugin augments Sequel's default model sharding support
# in the following ways:
#
# * It automatically saves model instances back to the
# shard they were retreived from.
# * It makes model associations use the same ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/tactical_eager_loading.rb | Ruby | mit | 5,086 | master | 8,882 | # frozen-string-literal: true
module Sequel
module Plugins
# The tactical_eager_loading plugin allows you to eagerly load
# an association for all objects retrieved from the same dataset
# without calling +eager+ on the dataset. If you attempt to load
# associated objects for a record and the associ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/concurrent_eager_loading.rb | Ruby | mit | 5,086 | master | 7,695 | # frozen-string-literal: true
module Sequel
extension 'async_thread_pool'
module Plugins
# The concurrent_eager_loading plugin allows for eager loading multiple associations
# concurrently in separate threads. You must load the async_thread_pool Database
# extension into the Database object the model... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/validation_class_methods.rb | Ruby | mit | 5,086 | master | 18,665 | # frozen-string-literal: true
module Sequel
module Plugins
# Sequel's built-in validation_class_methods plugin adds backwards compatibility
# for the legacy class-level validation methods (e.g. validates_presence_of :column).
#
# It is recommended to use the validation_helpers plugin instead of this ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/eager_graph_eager.rb | Ruby | mit | 5,086 | master | 5,307 | # frozen-string-literal: true
module Sequel
module Plugins
# The eager_graph_eager plugin allows for chaining eager loads after eager_graph
# loads. Given the following model associations:
#
# Band.one_to_many :albums
# Album.one_to_many :tracks
#
# Let's say you wanted to return ban... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/instance_hooks.rb | Ruby | mit | 5,086 | master | 4,352 | # frozen-string-literal: true
module Sequel
module Plugins
# The instance_hooks plugin allows you to add hooks to specific instances,
# by passing a block to a _hook method (e.g. before_save_hook{do_something}).
# The block is executed when the hook is called (e.g. before_save).
#
# All of the st... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/unused_associations.rb | Ruby | mit | 5,086 | master | 24,277 | # frozen-string-literal: true
# :nocov:
# This entire file is excluded from coverage testing. This is because it
# requires coverage testing to work, and if you've already loaded Sequel
# without enabling coverage, then coverage testing won't work correctly
# for methods defined by Sequel.
#
# While automated covera... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/lazy_attributes.rb | Ruby | mit | 5,086 | master | 5,013 | # frozen-string-literal: true
module Sequel
module Plugins
# The lazy_attributes plugin allows users to easily set that some attributes
# should not be loaded by default when loading model objects. If the attribute
# is needed after the instance has been retrieved, a database query is made to
# retr... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/require_valid_schema.rb | Ruby | mit | 5,086 | master | 2,591 | # frozen-string-literal: true
module Sequel
module Plugins
# The require_valid_schema plugin makes Sequel raise or warn if attempting
# to set the dataset of a model class to a simple table, where the database
# supports schema parsing, but schema parsing does not work for the model's
# table.
#
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/inverted_subsets.rb | Ruby | mit | 5,086 | master | 1,853 | # frozen-string-literal: true
module Sequel
module Plugins
# The inverted_subsets plugin adds another method for each defined
# subset, which inverts the condition supplied. By default, inverted
# subset method names are prefixed with not_.
#
# You can change the prefix, or indeed entirely custom... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/pg_auto_validate_enums.rb | Ruby | mit | 5,086 | master | 3,402 | # frozen-string-literal: true
module Sequel
module Plugins
# The pg_auto_validate_enums plugin implements automatic validations for
# enum columns, ensuring that enum columns have a valid value. With this
# plugin, trying to save with an invalid enum value results in
# Sequel::ValidationFailed befor... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/class_table_inheritance_constraint_validations.rb | Ruby | mit | 5,086 | master | 2,958 | # frozen_string_literal: true
require_relative 'constraint_validations'
require_relative 'class_table_inheritance'
module Sequel
module Plugins
# = Overview
#
# The class_table_inheritance_constraint_validations plugin extends the
# constraint_validations plugin to work correctly with the
# clas... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/optimistic_locking.rb | Ruby | mit | 5,086 | master | 1,732 | # frozen-string-literal: true
module Sequel
module Plugins
# This plugin implements a simple database-independent locking mechanism
# to ensure that concurrent updates do not override changes. This is
# best implemented by a code example:
#
# class Person < Sequel::Model
# plugin :opti... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/split_values.rb | Ruby | mit | 5,086 | master | 2,609 | # frozen-string-literal: true
module Sequel
module Plugins
# The split_values plugin splits the values hash retreived from the
# database, and moves keys from the values hash that are not columns
# in the model's dataset to a separate hash. This makes it so the
# values hash only stores columns from... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/pg_array_associations.rb | Ruby | mit | 5,086 | master | 22,011 | # frozen-string-literal: true
module Sequel
extension :pg_array, :pg_array_ops
module Plugins
# This plugin allows you to create associations where the foreign keys
# are stored in a PostgreSQL array column in one of the tables. The
# model with the table containing the array column has a
# pg_ar... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/boolean_subsets.rb | Ruby | mit | 5,086 | master | 2,470 | # frozen-string-literal: true
module Sequel
module Plugins
# The boolean_subsets plugin allows for the automatic creation of subsets for
# for boolean columns, which can DRY up model classes that define such subsets
# manually. By default, subsets are created for all columns of type :boolean,
# with... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/json_serializer.rb | Ruby | mit | 5,086 | master | 16,567 | # frozen-string-literal: true
require 'json'
module Sequel
module Plugins
# The json_serializer plugin handles serializing entire Sequel::Model
# objects to JSON, as well as support for deserializing JSON directly
# into Sequel::Model objects. It requires the json library, and can
# work with eithe... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/update_primary_key.rb | Ruby | mit | 5,086 | master | 2,367 | # frozen-string-literal: true
module Sequel
module Plugins
# The update_primary_key plugin allows you to modify an object's
# primary key and then save the record. Sequel does not work
# correctly with primary key modifications by default. Sequel
# is designed to work with surrogate primary keys th... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/force_encoding.rb | Ruby | mit | 5,086 | master | 2,781 | # frozen-string-literal: true
module Sequel
module Plugins
# The force_encoding plugin allows you force specific encodings for all
# strings that are used by the model. When model instances are loaded
# from the database, all values in the hash that are strings are
# forced to the given encoding. W... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/active_model.rb | Ruby | mit | 5,086 | master | 3,448 | # frozen-string-literal: true
require 'active_model'
module Sequel
module Plugins
# The active_model plugin makes Sequel::Model objects
# pass the ActiveModel::Lint tests, which should
# hopefully mean full ActiveModel compliance. This should
# allow the full support of Sequel::Model objects in Rail... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/forbid_lazy_load.rb | Ruby | mit | 5,086 | master | 8,255 | # frozen-string-literal: true
module Sequel
module Plugins
# The forbid_lazy_load plugin forbids lazy loading of associations
# for objects in cases where the object wasn't loaded with a
# method that only returns a single object.
#
# The main reason for doing this is it makes it easier to detect... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/primary_key_lookup_check_values.rb | Ruby | mit | 5,086 | master | 5,470 | # frozen-string-literal: true
module Sequel
module Plugins
# The primary_key_lookup_check_values plugin typecasts given primary key
# values before performing a lookup by primary key. If the given primary
# key value cannot be typecasted correctly, the lookup returns nil
# without issuing a query. I... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/enum.rb | Ruby | mit | 5,086 | master | 5,379 | # frozen-string-literal: true
module Sequel
module Plugins
# The enum plugin allows for easily adding methods to modify the value of
# a column. It allows treating the column itself as an enum, returning a
# symbol for the related enum value. It also allows for setting up dataset
# methods to easil... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/many_through_many.rb | Ruby | mit | 5,086 | master | 22,199 | # frozen-string-literal: true
module Sequel
module Plugins
# The many_through_many plugin allow you to create an association using multiple join tables.
# For example, assume the following associations:
#
# Artist.many_to_many :albums
# Album.many_to_many :tags
#
# The many_through_... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/auto_restrict_eager_graph.rb | Ruby | mit | 5,086 | master | 2,655 | # frozen-string-literal: true
module Sequel
module Plugins
# The auto_restrict_eager_graph plugin will automatically disallow the use
# of eager_graph for associations that have associated blocks but no :graph_*
# association options. The reason for this is the block will have an effect
# during reg... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/plugins/prepared_statements.rb | Ruby | mit | 5,086 | master | 8,017 | # frozen-string-literal: true
module Sequel
module Plugins
# The prepared_statements plugin modifies the model to use prepared statements for
# instance level inserts and updates. This plugin exists for backwards compatibility
# and is not recommended for general use.
#
# Note that this plugin is... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/base.rb | Ruby | mit | 5,086 | master | 90,129 | # frozen-string-literal: true
module Sequel
class Model
# SEQUEL6: Remove Enumerable here, and send all Enumerable methods to dataset
# by default, with a plugin for the current behavior.
extend Enumerable
extend Inflections
# Class methods for Sequel::Model that implement basic model functional... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/inflections.rb | Ruby | mit | 5,086 | master | 5,731 | # frozen-string-literal: true
module Sequel
# Yield the Inflections module if a block is given, and return
# the Inflections module.
def self.inflections
yield Inflections if defined?(yield)
Inflections
end
# This module acts as a singleton returned/yielded by Sequel.inflections,
# which is used t... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/errors.rb | Ruby | mit | 5,086 | master | 1,980 | # frozen-string-literal: true
module Sequel
class Model
# Errors represents validation errors, a simple hash subclass
# with a few convenience methods.
class Errors < ::Hash
# Adds an error for the given attribute.
#
# errors.add(:name, 'is not valid') if name == 'invalid'
def a... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/plugins.rb | Ruby | mit | 5,086 | master | 7,042 | # frozen-string-literal: true
module Sequel
# Empty namespace that plugins should use to store themselves,
# so they can be loaded via Model.plugin.
#
# Plugins should be modules with one of the following conditions:
# * A singleton method named apply, which takes a model,
# additional arguments, and an... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/dataset_module.rb | Ruby | mit | 5,086 | master | 988 | # frozen-string-literal: true
module Sequel
class Model
# This Module subclass is used by Model.dataset_module
# to add dataset methods to classes. In addition to the
# methods offered by Dataset::DatasetModule, it also
# automatically creates class methods for public dataset
# methods.
clas... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/default_inflections.rb | Ruby | mit | 5,086 | master | 1,599 | # frozen-string-literal: true
module Sequel
# Proc that is instance_execed to create the default inflections for both the
# model inflector and the inflector extension.
DEFAULT_INFLECTIONS_PROC = proc do
plural(/$/, 's')
plural(/s$/i, 's')
plural(/(alias|(?:stat|octop|vir|b)us)$/i, '\1es')
plural... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/exceptions.rb | Ruby | mit | 5,086 | master | 1,943 | # frozen-string-literal: true
module Sequel
# Exception class raised when +raise_on_save_failure+ is set and an action is canceled in a hook.
# or an around hook doesn't yield.
class HookFailed < Error
# The Sequel::Model instance related to this error.
attr_reader :model
def initialize(message=nil,... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/model/associations.rb | Ruby | mit | 5,086 | master | 195,881 | # frozen-string-literal: true
module Sequel
class Model
# Associations are used in order to specify relationships between model classes
# that reflect relations between tables in the database using foreign keys.
module Associations
# Map of association type symbols to association reflection classes... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/placeholder_literalizer.rb | Ruby | mit | 5,086 | master | 8,295 | # frozen-string-literal: true
module Sequel
class Dataset
# PlaceholderLiteralizer allows you to record the application of arbitrary changes
# to a dataset with placeholder arguments, recording where those placeholder arguments
# are used in the query. When running the query, the literalization process ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/query.rb | Ruby | mit | 5,086 | master | 66,262 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 1 - Methods that return modified datasets
# These methods all return modified copies of the receiver.
# ---------------------
# Hash of extension name symbols to callable objects to load the extension
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/dataset_module.rb | Ruby | mit | 5,086 | master | 1,500 | # frozen-string-literal: true
module Sequel
class Dataset
# This Module subclass is used by Database#extend_datasets
# and Dataset#with_extend to add dataset methods to classes.
# It adds some helper methods inside the module that can define
# named methods on the dataset instances which do specific ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/deprecated_singleton_class_methods.rb | Ruby | mit | 5,086 | master | 1,440 | # frozen-string-literal: true
module Sequel
class Dataset
# This module implements methods to support deprecated use of extensions registered
# not using a module. In such cases, for backwards compatibility, Sequel has to use
# a singleton class for the dataset.
module DeprecatedSingletonClassMethod... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/graph.rb | Ruby | mit | 5,086 | master | 12,936 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 5 - Methods related to dataset graphing
# Dataset graphing automatically creates unique aliases columns in join
# tables that overlap with already selected column aliases.
# All of these methods return ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/misc.rb | Ruby | mit | 5,086 | master | 12,004 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 6 - Miscellaneous methods
# These methods don't fit cleanly into another section.
# ---------------------
# The database related to this dataset. This is the Database instance that
# will execu... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/actions.rb | Ruby | mit | 5,086 | master | 53,388 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 2 - Methods that execute code on the database
# These methods all execute the dataset's SQL on the database.
# They don't return modified datasets, so if used in a method chain
# they should be the last ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/sql.rb | Ruby | mit | 5,086 | master | 57,468 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 3 - User Methods relating to SQL Creation
# These are methods you can call to see what SQL will be generated by the dataset.
# ---------------------
# Returns an EXISTS clause for the dataset as an ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/prepared_statements.rb | Ruby | mit | 5,086 | master | 16,758 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 8 - Methods related to prepared statements or bound variables
# On some adapters, these use native prepared statements and bound variables, on others
# support is emulated. For details, see the {"Prepared ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/dataset/features.rb | Ruby | mit | 5,086 | master | 8,601 | # frozen-string-literal: true
module Sequel
class Dataset
# ---------------------
# :section: 4 - Methods that describe what the dataset supports
# These methods all return booleans, with most describing whether or not the
# dataset supports a feature.
# ---------------------
# Whether t... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/misc.rb | Ruby | mit | 5,086 | master | 24,561 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 7 - Miscellaneous methods
# These methods don't fit neatly into another category.
# ---------------------
# Hash of extension name symbols to callable objects to load the extension
# into the D... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/query.rb | Ruby | mit | 5,086 | master | 15,266 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 1 - Methods that execute queries and/or return results
# This methods generally execute SQL code on the database server.
# ---------------------
COLUMN_SCHEMA_DATETIME_TYPES = [:date, :datetime].freeze... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/dataset_defaults.rb | Ruby | mit | 5,086 | master | 3,288 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 5 - Methods that set defaults for created datasets
# This methods change the default behavior of this database's datasets.
# ---------------------
# The class to use for creating datasets. Should resp... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/connecting.rb | Ruby | mit | 5,086 | master | 11,714 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 4 - Methods relating to adapters, connecting, disconnecting, and sharding
# This methods involve the Database's connection pool.
# ---------------------
# Array of supported database adapters
ADAPT... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/schema_generator.rb | Ruby | mit | 5,086 | master | 34,047 | # frozen-string-literal: true
module Sequel
# The Schema module holds the schema generators.
module Schema
module ColumnOptionMerger
private
# Merge given options into the column's default options. For backwards compatibility,
# the options take priority, but in cases where the option value ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/transactions.rb | Ruby | mit | 5,086 | master | 20,819 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 8 - Methods related to database transactions
# Database transactions make multiple queries atomic, so
# that either all of the queries take effect or none of
# them do.
# ---------------------
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/dataset.rb | Ruby | mit | 5,086 | master | 2,912 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 3 - Methods that create datasets
# These methods all return instances of this database's dataset class.
# ---------------------
# Returns a dataset for the database. If the first argument is a string,
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/schema_methods.rb | Ruby | mit | 5,086 | master | 44,102 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 2 - Methods that modify the database schema
# These methods execute code on the database that modifies the database's schema.
# ---------------------
# The order of column modifiers to use when definin... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/logging.rb | Ruby | mit | 5,086 | master | 3,091 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 6 - Methods relating to logging
# This methods affect relating to the logging of executed SQL.
# ---------------------
# Numeric specifying the duration beyond which queries are logged at warn
# le... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/database/features.rb | Ruby | mit | 5,086 | master | 4,749 | # frozen-string-literal: true
module Sequel
class Database
# ---------------------
# :section: 9 - Methods that describe what the database supports
# These methods all return booleans, with most describing whether or not the
# database supprots a given feature.
# ---------------------
# ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/_model_pg_row.rb | Ruby | mit | 5,086 | master | 777 | # frozen-string-literal: true
module Sequel
module Plugins
module PgRow
module DatabaseMethods
# Handle Sequel::Model instances in bound variables.
def bound_variable_arg(arg, conn)
case arg
when Sequel::Model
"(#{arg.values.values_at(*arg.columns).map{|v| bo... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/schema_caching.rb | Ruby | mit | 5,086 | master | 3,208 | # frozen-string-literal: true
#
# The schema_caching extension adds a few methods to Sequel::Database
# that make it easy to dump the parsed schema information to a file,
# and load it from that file. Loading the schema information from a
# dumped file is faster than parsing it from the database, so this
# can save bo... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_interval.rb | Ruby | mit | 5,086 | master | 7,569 | # frozen-string-literal: true
#
# The pg_interval extension adds support for PostgreSQL's interval type.
#
# This extension integrates with Sequel's native postgres and jdbc/postgresql
# adapters, so that when interval type values are retrieved, they are parsed and returned
# as instances of ActiveSupport::Duration.
#
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pagination.rb | Ruby | mit | 5,086 | master | 4,592 | # frozen-string-literal: true
#
# The pagination extension adds the Sequel::Dataset#paginate and #each_page methods,
# which return paginated (limited and offset) datasets with the following methods
# added that make creating a paginated display easier:
#
# * +page_size+
# * +page_count+
# * +page_range+
# * +current_p... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/identifier_mangling.rb | Ruby | mit | 5,086 | master | 6,310 | # frozen-string-literal: true
#
# The identifier_mangling extension adds support for to change
# the default identifier mangling for datasets, as well as all
# datasets for a given database.
#
# # Use uppercase identifiers in database, and lowercase in ruby.
# # Default behavior of Sequel, as the SQL standard behav... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_timestamptz.rb | Ruby | mit | 5,086 | master | 1,554 | # frozen-string-literal: true
#
# The pg_timestamptz extension changes the default timestamp
# type for the database to be +timestamptz+ (<tt>timestamp with time zone</tt>)
# instead of +timestamp+ (<tt>timestamp without time zone</tt>). This is
# recommended if you are dealing with multiple timezones in your applicat... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/virtual_row_method_block.rb | Ruby | mit | 5,086 | master | 1,335 | # frozen-string-literal: true
#
# These modifies virtual row blocks so that you can pass a block
# when calling a method to change the behavior. It only exists
# for backwards compatibility with previous Sequel versions, and
# is not recommended for new applications.
#
# To load the extension:
#
# Sequel.extension ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/date_parse_input_handler.rb | Ruby | mit | 5,086 | master | 2,120 | # frozen-string-literal: true
#
# The date_parse_input_handler extension allows for configuring how input
# to date parsing methods should be handled. By default, the
# extension does not change behavior. However, you can use the
# +Sequel.date_parse_input_handler+ method to support custom handling
# of input strings... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/eval_inspect.rb | Ruby | mit | 5,086 | master | 5,606 | # frozen-string-literal: true
#
# The eval_inspect extension changes #inspect for Sequel::SQL::Expression
# subclasses to return a string suitable for ruby's eval, such that
#
# eval(obj.inspect) == obj
#
# is true. The above code is true for most of ruby's simple classes such
# as String, Integer, Float, and Symbol... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/migration.rb | Ruby | mit | 5,086 | master | 29,800 | # frozen-string-literal: true
#
# Adds the Sequel::Migration and Sequel::Migrator classes, which allow
# the user to easily group schema changes and migrate the database
# to a newer version or revert to a previous version.
#
# To load the extension:
#
# Sequel.extension :migration
#
# Related modules: Sequel::Migrat... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/graph_each.rb | Ruby | mit | 5,086 | master | 2,772 | # frozen-string-literal: true
#
# The graph_each extension adds Dataset#graph_each and
# makes Dataset#each call #graph_each if the dataset has been graphed.
# Dataset#graph_each splits result hashes into subhashes per table:
#
# DB[:a].graph(:b, id: :b_id).all
# # => {:a=>{:id=>1, :b_id=>2}, :b=>{:id=>2}}
#
# You ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/_model_constraint_validations.rb | Ruby | mit | 5,086 | master | 507 | # frozen-string-literal: true
module Sequel
module Plugins
module ConstraintValidations
module DatabaseMethods
# A hash of validation method call metadata for all tables in the database.
# The hash is keyed by table name string and contains arrays of validation
# method call arrays.... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/implicit_subquery.rb | Ruby | mit | 5,086 | master | 1,562 | # frozen-string-literal: true
#
# The implicit_subquery extension changes most dataset methods that
# return modified datasets to implicitly call from_self if the database
# currently uses raw SQL. Sequel's by default does not do this:
#
# DB["SELECT * FROM table"].select(:column).sql
# # => "SELECT * FROM table"
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/sqlite_json_ops.rb | Ruby | mit | 5,086 | master | 10,774 | # frozen-string-literal: true
#
# The sqlite_json_ops extension adds support to Sequel's DSL to make
# it easier to call SQLite JSON functions and operators (added
# first in SQLite 3.38.0). It also supports the SQLite JSONB functions
# added in SQLite 3.45.0.
#
# To load the extension:
#
# Sequel.extension :sqlite_... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/exclude_or_null.rb | Ruby | mit | 5,086 | master | 2,365 | # frozen-string-literal: true
#
# The exclude_or_null extension adds Dataset#exclude_or_null and
# Dataset#exclude_or_null_having. These methods are similar to
# Dataset#exclude and Dataset#exclude_having, except that they
# will also exclude rows where the condition IS NULL.
#
# DB[:table].exclude_or_null(foo: 1)
#... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/integer64.rb | Ruby | mit | 5,086 | master | 1,034 | # frozen-string-literal: true
#
# The integer64 extension changes the default type used for Integer
# to be the same type as used for :Bignum. In general, this means that
# instead of Integer resulting in a 32-bit database integer type, it will
# result in a 64-bit database integer type. This affects the default
# ty... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/null_dataset.rb | Ruby | mit | 5,086 | master | 3,093 | # frozen-string-literal: true
#
# The null_dataset extension adds the Dataset#nullify method, which
# returns a cloned dataset that will never issue a query to the
# database. It implements the null object pattern for datasets.
#
# The most common usage is probably in a method that must return
# a dataset, where the m... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_auto_parameterize.rb | Ruby | mit | 5,086 | master | 18,078 | # frozen-string-literal: true
#
# This extension changes Sequel's postgres adapter to automatically
# parameterize queries by default. Sequel's default behavior has always
# been to literalize all arguments unless specifically using
# parameters (via :$arg placeholders and the Dataset#prepare/call methods).
# This ext... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_row_ops.rb | Ruby | mit | 5,086 | master | 6,610 | # frozen-string-literal: true
#
# The pg_row_ops extension adds support to Sequel's DSL to make
# it easier to deal with PostgreSQL row-valued/composite types.
#
# To load the extension:
#
# Sequel.extension :pg_row_ops
#
# The most common usage is passing an expression to Sequel.pg_row_op:
#
# r = Sequel.pg_row_op... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/async_thread_pool.rb | Ruby | mit | 5,086 | master | 16,534 | # frozen-string-literal: true
#
# The async_thread_pool extension adds support for running database
# queries in a separate threads using a thread pool. With the following
# code
#
# DB.extension :async_thread_pool
# foos = DB[:foos].async.where(name: 'A'..'M').all
# bar_names = DB[:bar].async.select_order_map(:n... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/query.rb | Ruby | mit | 5,086 | master | 2,347 | # frozen-string-literal: true
#
# The query extension adds a query method which allows
# a different way to construct queries instead of the usual
# method chaining:
#
# dataset = DB[:items].query do
# select :x, :y, :z
# where{(x > 1) & (y > 2)}
# reverse :z
# end
#
# You can load this extension into s... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/provenance.rb | Ruby | mit | 5,086 | master | 3,643 | # frozen-string-literal: true
#
# The provenance dataset extension tracks the locations of all
# dataset clones that resulted in the current dataset, and includes
# the information as a comment in the dataset's SQL. This makes it
# possible to see how a query was built, which can aid debugging.
# Example:
#
# DB[:ta... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.