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/extensions/pg_range_ops.rb | Ruby | mit | 5,086 | master | 6,241 | # frozen-string-literal: true
#
# The pg_range_ops extension adds support to Sequel's DSL to make
# it easier to call PostgreSQL range and multirange functions and operators.
#
# To load the extension:
#
# Sequel.extension :pg_range_ops
#
# The most common usage is passing an expression to Sequel.pg_range_op:
#
# r... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_array.rb | Ruby | mit | 5,086 | master | 22,032 | # frozen-string-literal: true
#
# The pg_array extension adds support for Sequel to handle
# PostgreSQL's array types.
#
# This extension integrates with Sequel's native postgres adapter and
# the jdbc/postgresql adapter, so that when array fields are retrieved,
# they are parsed and returned as instances of Sequel::Po... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/thread_local_timezones.rb | Ruby | mit | 5,086 | master | 2,164 | # frozen-string-literal: true
#
# 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 o... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/blank.rb | Ruby | mit | 5,086 | master | 923 | # frozen-string-literal: true
#
# The blank extension adds the blank? method to all objects (e.g. Object#blank?).
#
# To load the extension:
#
# Sequel.extension :blank
[FalseClass, Object, NilClass, Numeric, String, TrueClass].each do |klass|
# :nocov:
if klass.method_defined?(:blank?)
klass.send(:alias_met... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_static_cache_updater.rb | Ruby | mit | 5,086 | master | 5,638 | # frozen-string-literal: true
#
# The pg_static_cache_updater extension is designed to
# automatically update the caches in the models using the
# static_cache plugin when changes to the underlying tables
# are detected.
#
# Before using the extension in production, you have to add
# triggers to the tables for the clas... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_json.rb | Ruby | mit | 5,086 | master | 20,206 | # frozen-string-literal: true
#
# The pg_json extension adds support for Sequel to handle
# PostgreSQL's json and jsonb types. By default, it wraps
# JSON arrays and JSON objects with ruby array-like and
# hash-like objects. If you would like to wrap JSON primitives
# (numbers, strings, +null+, +true+, and +false+), ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_enum.rb | Ruby | mit | 5,086 | master | 6,742 | # frozen-string-literal: true
#
# The pg_enum extension adds support for Sequel to handle PostgreSQL's enum
# types. To use this extension, first load it into your Database instance:
#
# DB.extension :pg_enum
#
# It allows creation of enum types using create_enum:
#
# DB.create_enum(:enum_type_name, %w'value1 valu... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/core_extensions.rb | Ruby | mit | 5,086 | master | 8,217 | # frozen-string-literal: true
#
# These are extensions to core classes that Sequel enables by default.
# They make using Sequel's DSL easier by adding methods to Array,
# Hash, String, and Symbol to add methods that return Sequel
# expression objects. To load the extension:
#
# Sequel.extension :core_extensions
# T... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/symbol_aref_refinement.rb | Ruby | mit | 5,086 | master | 1,124 | # frozen-string-literal: true
#
# The symbol_aref_refinement extension adds a refinement that makes
# Symbol#[] support Symbol, #Sequel::SQL::Indentifier, and
# Sequel::SQL::QualifiedIdentifier instances, returning appropriate
# Sequel::SQL::QualifiedIdentifier instances. It's designed as a
# shortcut so that instead ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_loose_count.rb | Ruby | mit | 5,086 | master | 1,130 | # frozen-string-literal: true
#
# The pg_loose_count extension looks at the table statistics
# in the PostgreSQL system tables to get a fast approximate
# count of the number of rows in a given table:
#
# DB.loose_count(:table) # => 123456
#
# It can also support schema qualified tables:
#
# DB.loose_count(Sequel[:... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/auto_literal_strings.rb | Ruby | mit | 5,086 | master | 2,188 | # frozen-string-literal: true
#
# The auto_literal_strings extension treats string values passed as filter
# arguments as SQL query fragments. This is the behavior of previous
# versions of Sequel. Using this extension makes using raw SQL fragments
# easier, since you don't need to wrap them with Sequel.lit, but also... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/current_datetime_timestamp.rb | Ruby | mit | 5,086 | master | 2,006 | # frozen-string-literal: true
#
# The current_datetime_timestamp extension makes Dataset#current_datetime
# return an object that operates like Sequel.datetime_class.now, but will
# be literalized as CURRENT_TIMESTAMP.
#
# This allows you to use the defaults_setter, timestamps, and touch
# model plugins and make sure t... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_inet.rb | Ruby | mit | 5,086 | master | 4,437 | # frozen-string-literal: true
#
# The pg_inet extension adds support for Sequel to handle
# PostgreSQL's inet and cidr types using ruby's IPAddr class.
#
# This extension integrates with Sequel's native postgres and jdbc/postgresql
# adapters, so that when inet/cidr fields are retrieved, they are returned as
# IPAddr i... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_auto_parameterize_duplicate_query_detection.rb | Ruby | mit | 5,086 | master | 7,313 | # frozen-string-literal: true
#
# The pg_auto_parameterize_duplicate_query_detection extension builds on the
# pg_auto_parameterize extension, adding support for detecting duplicate
# queries inside a block that occur at the same location. This is designed
# mostly to catch duplicate query issues (e.g. N+1 queries) dur... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/connection_checkout_event_callback.rb | Ruby | mit | 5,086 | master | 4,706 | # frozen-string-literal: true
#
# The connection_checkout_event_callback extension modifies a database's
# connection pool to allow for a checkout event callback. This callback is
# called with the following arguments:
#
# :immediately_available :: Connection immediately available and returned
# :not_immediately_availa... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/sequel_4_dataset_methods.rb | Ruby | mit | 5,086 | master | 2,803 | # frozen-string-literal: true
#
# This adds the following dataset methods:
#
# and :: alias for where
# exclude_where :: alias for exclude
# interval :: Returns max - min, using a single query
# range :: Returns min..max, using a single query
#
# It is only recommended to use this for backwards compatibility.
#
# You c... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/constraint_validations.rb | Ruby | mit | 5,086 | master | 20,843 | # frozen-string-literal: true
#
# The constraint_validations extension is designed to easily create database
# constraints inside create_table and alter_table blocks. It also adds
# relevant metadata about the constraints to a separate table, which the
# constraint_validations model plugin uses to setup automatic vali... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/schema_dumper.rb | Ruby | mit | 5,086 | master | 22,298 | # frozen-string-literal: true
#
# 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_mig... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/lit_require_frozen.rb | Ruby | mit | 5,086 | master | 4,053 | # frozen-string-literal: true
#
# The lit_require_frozen extension disallows the use of unfrozen strings
# as literal strings in database and dataset methods. If you try to use an
# unfrozen string as a literal string for a dataset using this extension,
# an exception will be raised.
#
# While this works for all Ruby v... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/round_timestamps.rb | Ruby | mit | 5,086 | master | 1,505 | # frozen-string-literal: true
#
# The round_timestamps extension will automatically round timestamp
# values to the database's supported level of precision before literalizing
# them.
#
# For example, if the database supports millisecond precision, and you give
# it a Time value with microsecond precision, it will roun... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/constant_sql_override.rb | Ruby | mit | 5,086 | master | 1,978 | # frozen-string-literal: true
#
# The constant_sql_override extension allows you to change the SQL
# generated for Sequel constants.
#
# One possible use-case for this is to have Sequel::CURRENT_TIMESTAMP use UTC time when
# you have Sequel.database_timezone = :utc, but the database uses localtime when
# generating CUR... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/symbol_as_refinement.rb | Ruby | mit | 5,086 | master | 914 | # frozen-string-literal: true
#
# The symbol_as_refinement extension adds a refinement that makes
# Symbol#as return Sequel::SQL::AliasedExpression instances. It's
# designed as a shortcut so that instead of:
#
# Sequel[:column].as(:alias) # column AS alias
#
# you can just write:
#
# :column.as(:alias) # colum... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/stdio_logger.rb | Ruby | mit | 5,086 | master | 1,477 | # frozen-string-literal: true
#
# The stdio_logger extension exposes a Sequel::StdioLogger class that
# can be used for logging with Sequel, as a minimal alternative to
# the logger library. It exposes debug/info/warn/error methods for the
# different warning levels. The debug method is a no-op, so that setting
# the... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_extended_integer_support.rb | Ruby | mit | 5,086 | master | 4,242 | # frozen-string-literal: true
#
# The pg_extended_integer_support extension supports literalizing
# Ruby integers outside of PostgreSQL bigint range on PostgreSQL.
# Sequel by default will raise exceptions when
# literalizing such integers, as PostgreSQL would treat them
# as numeric type values instead of integer/bigi... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/arbitrary_servers.rb | Ruby | mit | 5,086 | master | 3,277 | # frozen-string-literal: true
#
# The arbitrary_servers extension allows you to connect to arbitrary
# servers/shards that were not defined when you created the database.
# To use it, you first load the extension into the Database object:
#
# DB.extension :arbitrary_servers
#
# Then you can pass arbitrary connection ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/string_agg.rb | Ruby | mit | 5,086 | master | 5,688 | # frozen-string-literal: true
#
# The string_agg extension adds the ability to perform database-independent
# aggregate string concatentation. For example, with a table like:
#
# c1 | c2
# ---+---
# a | 1
# a | 2
# a | 3
# b | 4
#
# You can return a result set like:
#
# c1 | c2s
# ---+---
# a | ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_range.rb | Ruby | mit | 5,086 | master | 21,063 | # frozen-string-literal: true
#
# The pg_range extension adds support for the PostgreSQL 9.2+ range
# types to Sequel. PostgreSQL range types are similar to ruby's
# Range class, representating an array of values. However, they
# are more flexible than ruby's ranges, allowing exclusive beginnings
# and endings (ruby'... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/connection_expiration.rb | Ruby | mit | 5,086 | master | 3,476 | # frozen-string-literal: true
#
# The connection_expiration extension modifies a database's
# connection pool to validate that connections checked out
# from the pool are not expired, before yielding them for
# use. If it detects an expired connection, it removes it
# from the pool and tries the next available connect... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/any_not_empty.rb | Ruby | mit | 5,086 | master | 1,289 | # frozen-string-literal: true
#
# The any_not_empty extension changes the behavior of Dataset#any?
# if called without a block. By default, this method uses the
# standard Enumerable behavior of enumerating results and seeing
# if any result is not false or nil. With this extension, it
# just checks whether the datas... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/index_caching.rb | Ruby | mit | 5,086 | master | 3,556 | # frozen-string-literal: true
#
# The index_caching extension adds a few methods to Sequel::Database
# that make it easy to dump information about database indexes to a file,
# and load it from that file. Loading index information from a
# dumped file is faster than parsing it from the database, so this
# can save boo... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/symbol_as.rb | Ruby | mit | 5,086 | master | 527 | # frozen-string-literal: true
#
# The symbol_as extension adds Symbol#as, for creating
# Sequel::SQL::AliasedExpression objects. It's
# designed as a shortcut so that instead of:
#
# Sequel[:column].as(:alias)
#
# you can just write:
#
# :column.as(:alias)
#
# To load the extension:
#
# Sequel.extension :symbol_a... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/sql_expr.rb | Ruby | mit | 5,086 | master | 567 | # frozen-string-literal: true
#
# The sql_expr extension adds the sql_expr method to every object, which
# returns an wrapped object that works nicely with Sequel's DSL by calling
# Sequel.expr:
#
# 1.sql_expr < :a # 1 < a
# false.sql_expr & :a # FALSE AND a
# true.sql_expr | :a # TRUE OR a
# ~nil.sql_expr... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_inet_ops.rb | Ruby | mit | 5,086 | master | 6,124 | # frozen-string-literal: true
#
# The pg_inet_ops extension adds support to Sequel's DSL to make
# it easier to call PostgreSQL inet functions and operators.
#
# To load the extension:
#
# Sequel.extension :pg_inet_ops
#
# The most common usage is passing an expression to Sequel.pg_inet_op:
#
# r = Sequel.pg_inet_o... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_hstore.rb | Ruby | mit | 5,086 | master | 10,806 | # frozen-string-literal: true
#
# The pg_hstore extension adds support for the PostgreSQL hstore type
# to Sequel. hstore is an extension that ships with PostgreSQL, and
# the hstore type stores an arbitrary key-value table, where the keys
# are strings and the values are strings or NULL.
#
# This extension integrates... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/dataset_source_alias.rb | Ruby | mit | 5,086 | master | 3,139 | # frozen-string-literal: true
#
# The dataset_source_alias extension changes Sequel's
# default behavior of automatically aliasing datasets
# from using t1, t2, etc. to using an alias based on
# the source of the dataset. Example:
#
# DB.from(DB.from(:a))
# # default: SELECT * FROM (SELECT * FROM a) AS t1
# # wi... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/empty_array_consider_nulls.rb | Ruby | mit | 5,086 | master | 1,382 | # frozen-string-literal: true
#
# This changes Sequel's literalization of IN/NOT IN with an empty
# array value to consider NULL values if one of the referenced
# columns is NULL:
#
# DB[:test].where(name: [])
# # SELECT * FROM test WHERE (name != name)
# DB[:test].exclude(name: [])
# # SELECT * FROM test WHERE... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/fiber_concurrency.rb | Ruby | mit | 5,086 | master | 644 | # frozen-string-literal: true
#
# The fiber_concurrency extension changes the default concurrency
# primitive in Sequel to be Fiber.current instead of Thread.current.
# This is the value used in various hash keys to implement safe
# concurrency (thread-safe concurrency by default, fiber-safe
# concurrency with this ext... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/dataset_run.rb | Ruby | mit | 5,086 | master | 1,226 | # frozen-string-literal: true
#
# The dataset_run extension is designed for cases where you want
# to use dataset methods to build a query, but want to run that
# query without returning a result. The most common need would
# be to easily use placeholders in an SQL string, which Database#run
# does not support directl... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/escaped_like.rb | Ruby | mit | 5,086 | master | 4,176 | # frozen-string-literal: true
#
# The escaped_like extension adds +escaped_like+ and +escaped_ilike+
# methods to Sequel::SQL::StringMethods, which allow them to be easily
# used with most of Sequel's expression objects. Example:
#
# DB[:table].where{string_column.escaped_like('?%', user_input)}
# # user_input is ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/date_arithmetic.rb | Ruby | mit | 5,086 | master | 9,993 | # frozen-string-literal: true
#
# The date_arithmetic extension adds the ability to perform database-independent
# addition/substraction of intervals to/from dates and timestamps.
#
# First, you need to load the extension into the database:
#
# DB.extension :date_arithmetic
#
# Then you can use the Sequel.date_add an... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/s.rb | Ruby | mit | 5,086 | master | 1,416 | # frozen-string-literal: true
#
# The s extension adds Sequel::S, a module containing a private #S
# method that calls Sequel.expr. It's designed as a shortcut so
# that instead of:
#
# Sequel.expr(:column) + 1
# # or
# Sequel.expr{column + 1}
#
# you can just write:
#
# S(:column) + 1
# # or
# S{column + ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/transaction_connection_validator.rb | Ruby | mit | 5,086 | master | 2,923 | # frozen-string-literal: true
#
# The transaction_connection_validator extension automatically
# retries a transaction on a connection if an disconnect error
# is raised when sending the statement to begin a new
# transaction, as long as the user has not already checked out
# a connection. This is safe to do because n... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/named_timezones.rb | Ruby | mit | 5,086 | master | 7,564 | # frozen-string-literal: true
#
# Allows the use of named timezones via TZInfo (requires tzinfo).
# Forces the use of DateTime as Sequel's datetime_class, since
# historically, Ruby's Time class doesn't support timezones other
# than local and UTC. To continue using Ruby's Time class when using
# the named_timezones ex... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/server_logging.rb | Ruby | mit | 5,086 | master | 1,892 | # frozen-string-literal: true
#
# The server_logging extension makes the logger include the server/shard
# the query was issued on. This makes it easier to use the logs when
# using sharding.
#
# Example:
#
# DB.opts[:server]
# # {:read_only=>{}, :b=>{}}
# DB.extension :server_logging
# DB[:a].all
# # (0.000... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/server_block.rb | Ruby | mit | 5,086 | master | 5,608 | # frozen-string-literal: true
#
# The server_block extension adds the Database#with_server method, which takes a shard
# argument and a block, and makes it so that access inside the block will use the
# specified shard by default.
#
# First, you need to enable it on the database object:
#
# DB.extension :server_block... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/duplicate_columns_handler.rb | Ruby | mit | 5,086 | master | 3,578 | # frozen-string-literal: true
#
# The duplicate_columns_handler extension allows you to customize handling of
# duplicate column names in your queries on a per-database or per-dataset level.
#
# For example, you may want to raise an exception if you join 2 tables together
# which contains a column that will override an... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/caller_logging.rb | Ruby | mit | 5,086 | master | 2,415 | # frozen-string-literal: true
#
# The caller_logging extension includes caller information before
# query logging, showing which code caused the query. It skips
# internal Sequel code, showing the first non-Sequel caller line.
#
# DB.extension :caller_logging
# DB[:table].first
# # Logger:
# # (0.000041s) (sou... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_json_ops.rb | Ruby | mit | 5,086 | master | 53,050 | # frozen-string-literal: true
#
# The pg_json_ops extension adds support to Sequel's DSL to make
# it easier to call PostgreSQL JSON functions and operators (added
# first in PostgreSQL 9.3). It also supports the JSONB functions
# and operators added in PostgreSQL 9.4, as well as additional
# functions and operators a... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/sql_comments.rb | Ruby | mit | 5,086 | master | 6,471 | # frozen-string-literal: true
#
# The sql_comments extension adds Dataset#comment to the datasets,
# allowing you to set SQL comments in the resulting query. These
# comments are appended to the end of the SQL query:
#
# ds = DB[:table].comment("Some Comment").all
# # SELECT * FROM table -- Some Comment
# #
#
# ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/split_array_nil.rb | Ruby | mit | 5,086 | master | 2,541 | # frozen-string-literal: true
#
# The split_array_nil extension overrides Sequel's default handling of
# IN/NOT IN with arrays of values to do specific nil checking. For example,
#
# ds = DB[:table].where(column: [1, nil])
#
# By default, that produces the following SQL:
#
# SELECT * FROM table WHERE (column IN (... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_auto_parameterize_in_array.rb | Ruby | mit | 5,086 | master | 7,639 | # frozen-string-literal: true
#
# The pg_auto_parameterize_in_array extension builds on the pg_auto_parameterize
# extension, adding support for handling additional types when converting from
# IN to = ANY and NOT IN to != ALL:
#
# DB[:table].where(column: [1.0, 2.0, ...])
# # Without extension: column IN ($1::nume... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/set_literalizer.rb | Ruby | mit | 5,086 | master | 1,187 | # frozen-string-literal: true
#
# The set_literalizer extension should no longer be used, as Sequel
# now supports Set values by default. For backwards compatibility
# the set_literalizer extension will treat a set that contains only
# 2 element arrays as a condition specifier (matching the behavior
# for arrays where ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/sql_log_normalizer.rb | Ruby | mit | 5,086 | master | 3,534 | # frozen-string-literal: true
#
# The sql_log_normalizer extension normalizes the SQL that is logged,
# removing the literal strings and numbers in the SQL, and removing the
# logging of any bound variables:
#
# ds = DB[:table].first(a: 1, b: 'something')
# # Without sql_log_normalizer extension
# # SELECT * FROM... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/string_date_time.rb | Ruby | mit | 5,086 | master | 1,453 | # frozen-string-literal: true
#
# The string_date_time extension provides String instance methods
# for converting the strings to a date (e.g. String#to_date), allowing
# for backwards compatibility with legacy Sequel code.
#
# These methods calls +parse+ on the related class, and as such, can
# result in denial of ser... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/inflector.rb | Ruby | mit | 5,086 | master | 9,243 | # frozen-string-literal: true
#
# The inflector extension adds inflection instance methods to String, which allows the easy transformation of
# words from singular to plural, class names to table names, modularized class
# names to ones without, and class names to foreign keys. It exists for
# backwards compatibility... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/mssql_emulate_lateral_with_apply.rb | Ruby | mit | 5,086 | master | 2,807 | # frozen-string-literal: true
#
# The mssql_emulate_lateral_with_apply extension converts
# queries that use LATERAL into queries that use CROSS/OUTER
# APPLY, allowing code that works on databases that support
# LATERAL via Dataset#lateral to run on Microsoft SQL Server
# and Sybase SQLAnywhere.
#
# This is available ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/auto_cast_date_and_time.rb | Ruby | mit | 5,086 | master | 2,544 | # frozen-string-literal: true
#
# The auto_cast_date_and_time extension uses SQL standard type casting
# when literalizing date, time, and timestamp values:
#
# DB.literal(Time.now)
# # => "TIMESTAMP '...'"
#
# DB.literal(Date.today)
# # => "DATE '...'"
#
# DB.literal(Sequel::SQLTime.create(10, 20, 30))
# #... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_row.rb | Ruby | mit | 5,086 | master | 21,199 | # frozen-string-literal: true
#
# The pg_row extension adds support for Sequel to handle
# PostgreSQL's row-valued/composite types.
#
# This extension integrates with Sequel's native postgres and jdbc/postgresql adapters, so
# that when composite fields are retrieved, they are parsed and returned
# as instances of Sequ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_multirange.rb | Ruby | mit | 5,086 | master | 13,801 | # frozen-string-literal: true
#
# The pg_multirange extension adds support for the PostgreSQL 14+ multirange
# types to Sequel. PostgreSQL multirange types are similar to an array of
# ranges, where a match against the multirange is a match against any of the
# ranges in the multirange.
#
# When PostgreSQL multirange ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/core_refinements.rb | Ruby | mit | 5,086 | master | 8,918 | # frozen-string-literal: true
#
# These are refinements to core classes that allow the Sequel
# DSL to be used without modifying the core classes directly.
# After loading the extension via:
#
# Sequel.extension :core_refinements
#
# you can enable the refinements for particular files:
#
# using Sequel::CoreRefinem... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/connection_validator.rb | Ruby | mit | 5,086 | master | 4,724 | # frozen-string-literal: true
#
# The connection_validator extension modifies a database's
# connection pool to validate that connections checked out
# from the pool are still valid, before yielding them for
# use. If it detects an invalid connection, it removes it
# from the pool and tries the next available connecti... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/query_blocker.rb | Ruby | mit | 5,086 | master | 5,397 | # frozen-string-literal: true
#
# The query_blocker extension adds Database#block_queries.
# Inside the block passed to #block_queries, any attempts to
# execute a query/statement on the database will raise a
# Sequel::QueryBlocker::BlockedQuery exception.
#
# DB.extension :query_blocker
# DB.block_queries do
# ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_hstore_ops.rb | Ruby | mit | 5,086 | master | 13,265 | # frozen-string-literal: true
#
# The pg_hstore_ops extension adds support to Sequel's DSL to make
# it easier to call PostgreSQL hstore functions and operators.
#
# To load the extension:
#
# Sequel.extension :pg_hstore_ops
#
# The most common usage is taking an object that represents an SQL
# expression (such as a ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/synchronize_sql.rb | Ruby | mit | 5,086 | master | 1,794 | # frozen-string-literal: true
#
# The synchronize_sql extension checks out a connection from the pool while
# generating an SQL string. In cases where a connection is necessary
# in order to properly escape input, and multiple inputs in the query need
# escaping, this can result in fewer connection checkouts and bette... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/select_remove.rb | Ruby | mit | 5,086 | master | 2,271 | # frozen-string-literal: true
#
# The select_remove extension adds select_remove for removing existing selected
# columns from a dataset. It's not part of Sequel core as it is rarely needed and has
# some corner cases where it can't work correctly.
#
# You can load this extension into specific datasets:
#
# ds = DB[... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/datetime_parse_to_time.rb | Ruby | mit | 5,086 | master | 1,372 | # frozen-string-literal: true
#
# This switches the default parsing of strings into Time values
# from using Time.parse to using DateTime.parse.to_time. This
# fixes issues when the times being parsed have no timezone
# information, the implicit timezone for the Database instance
# is set to +:utc+, and the timestamps... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_array_ops.rb | Ruby | mit | 5,086 | master | 11,545 | # frozen-string-literal: true
#
# The pg_array_ops extension adds support to Sequel's DSL to make
# it easier to call PostgreSQL array functions and operators.
#
# To load the extension:
#
# Sequel.extension :pg_array_ops
#
# The most common usage is passing an expression to Sequel.pg_array_op:
#
# ia = Sequel.pg_a... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/symbol_aref.rb | Ruby | mit | 5,086 | master | 1,308 | # frozen-string-literal: true
#
# The symbol_aref extension makes Symbol#[] support Symbol,
# Sequel::SQL::Indentifier, and Sequel::SQL::QualifiedIdentifier instances,
# returning appropriate Sequel::SQL::QualifiedIdentifier instances. It's
# designed as a shortcut so that instead of:
#
# Sequel[:table][:column] # t... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/error_sql.rb | Ruby | mit | 5,086 | master | 2,534 | # frozen-string-literal: true
#
# The error_sql extension adds a DatabaseError#sql method
# that you can use to get the sql that caused the error
# to be raised.
#
# begin
# DB.run "Invalid SQL"
# rescue => e
# puts e.sql # "Invalid SQL"
# end
#
# On some databases, the error message contains part or all
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/columns_introspection.rb | Ruby | mit | 5,086 | master | 2,655 | # frozen-string-literal: true
#
# 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-p... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pretty_table.rb | Ruby | mit | 5,086 | master | 954 | # frozen-string-literal: true
#
# The pretty_table extension adds Sequel::Dataset#print and the
# Sequel::PrettyTable class for creating nice-looking plain-text
# tables. Example:
#
# +--+-------+
# |id|name |
# |--+-------|
# |1 |fasdfas|
# |2 |test |
# +--+-------+
#
# You can load this extension int... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_schema_caching.rb | Ruby | mit | 5,086 | master | 2,868 | # frozen-string-literal: true
#
# The pg_schema_caching extension builds on top of the schema_caching
# extension, and allows it to handle custom PostgreSQL types. On
# PostgreSQL, column schema hashes include an :oid entry for the OID
# for the column's type. For custom types, this OID is dependent on
# the PostgreSQ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/temporarily_release_connection.rb | Ruby | mit | 5,086 | master | 5,955 | # frozen-string-literal: true
#
# The temporarily_release_connection extension adds support for temporarily
# releasing a checked out connection back to the connection pool. It is
# designed for use in multithreaded transactional integration tests, allowing
# a connection to start a transaction in one thread, but be t... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/is_distinct_from.rb | Ruby | mit | 5,086 | master | 4,252 | # frozen-string-literal: true
#
# The is_distinct_from extension adds the ability to use the
# SQL standard IS DISTINCT FROM operator, which is similar to the
# not equals operator, except that NULL values are considered
# equal. PostgreSQL, SQLite 3.39+, and H2 currently support this operator. On
# other databases,... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/looser_typecasting.rb | Ruby | mit | 5,086 | master | 1,269 | # frozen-string-literal: true
#
# The LooserTypecasting extension loosens the default database typecasting
# for the following types:
#
# :float :: use to_f instead of Float()
# :integer :: use to_i instead of Integer()
# :decimal :: use 0.0 for unsupported strings
# :string :: silently allow hash and array conversion ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/pg_extended_date_support.rb | Ruby | mit | 5,086 | master | 8,430 | # frozen-string-literal: true
#
# The pg_extended_date_support extension allows support
# for BC dates/timestamps by default, and infinite
# dates/timestamps if configured. Without this extension,
# BC and infinite dates/timestamps will be handled incorrectly
# or raise an error. This behavior isn't the default becau... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/to_dot.rb | Ruby | mit | 5,086 | master | 4,784 | # frozen-string-literal: true
#
# This adds a <tt>Sequel::Dataset#to_dot</tt> 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.
#
# To load the extens... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/run_transaction_hooks.rb | Ruby | mit | 5,086 | master | 2,037 | # frozen-string-literal: true
#
# The run_transaction_hooks extension allows for running after_commit or
# after_rollback extensions before commit or rollback. It then removes
# the hook after running it, so it will not be run twice.
#
# This extension should only be used in transactional tests where the
# transaction... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/extensions/_pretty_table.rb | Ruby | mit | 5,086 | master | 2,342 | # frozen-string-literal: true
#
# This _pretty_table extension is only for internal use.
# It adds the Sequel::PrettyTable class without modifying
# Sequel::Dataset.
#
# To load the extension:
#
# Sequel.extension :_pretty_table
#
# Related module: Sequel::PrettyTable
#
module Sequel
module PrettyTable
# Prin... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/connection_pool/threaded.rb | Ruby | mit | 5,086 | master | 9,997 | # frozen-string-literal: true
# A connection pool allowing multi-threaded access to a pool of connections.
# This is the default connection pool used by Sequel.
class Sequel::ThreadedConnectionPool < Sequel::ConnectionPool
USE_WAITER = true # SEQUEL6: Remove
Sequel::Deprecation.deprecate_constant(self, :USE_WAITER... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/connection_pool/sharded_single.rb | Ruby | mit | 5,086 | master | 3,619 | # frozen-string-literal: true
# A ShardedSingleConnectionPool is a single threaded connection pool that
# works with multiple shards/servers.
class Sequel::ShardedSingleConnectionPool < Sequel::ConnectionPool
# The single threaded pool takes the following options:
#
# :servers :: A hash of servers to use. Keys ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/connection_pool/single.rb | Ruby | mit | 5,086 | master | 1,250 | # frozen-string-literal: true
# This is the fastest connection pool, since it isn't a connection pool at all.
# It is just a wrapper around a single connection that uses the connection pool
# API.
class Sequel::SingleConnectionPool < Sequel::ConnectionPool
def initialize(db, opts=OPTS)
super
@conn = []
e... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/connection_pool/sharded_threaded.rb | Ruby | mit | 5,086 | master | 13,729 | # frozen-string-literal: true
require_relative 'threaded'
# The slowest and most advanced connection pool, dealing with both multi-threaded
# access and configurations with multiple shards/servers.
#
# In addition, this pool subclass also handles scheduling in-use connections
# to be removed from the pool when they a... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/connection_pool/sharded_timed_queue.rb | Ruby | mit | 5,086 | master | 13,676 | # frozen-string-literal: true
# :nocov:
raise LoadError, "Sequel::ShardedTimedQueueConnectionPool is only available on Ruby 3.2+" unless RUBY_VERSION >= '3.2'
# :nocov:
# A connection pool allowing multi-threaded access to a sharded pool of connections,
# using a timed queue (only available in Ruby 3.2+).
class Seque... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | lib/sequel/connection_pool/timed_queue.rb | Ruby | mit | 5,086 | master | 9,357 | # frozen-string-literal: true
# :nocov:
raise LoadError, "Sequel::TimedQueueConnectionPool is only available on Ruby 3.2+" unless RUBY_VERSION >= '3.2'
# :nocov:
# A connection pool allowing multi-threaded access to a pool of connections,
# using a timed queue (only available in Ruby 3.2+).
class Sequel::TimedQueueCo... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/bin_spec.rb | Ruby | mit | 5,086 | master | 13,279 | # frozen_string_literal: true
require 'rbconfig'
require 'yaml'
if ENV['COVERAGE']
require_relative "sequel_coverage"
SimpleCov.sequel_coverage(:subprocesses=>true)
end
RUBY = RbConfig.ruby
OUTPUT = "spec/bin-sequel-spec-output-#{$$}.log"
TMP_FILE = "spec/bin-sequel-tmp-#{$$}.rb"
BIN_SPEC_DB = "spec/bin-sequel-sp... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/visibility_checking_after_hook.rb | Ruby | mit | 5,086 | master | 1,147 | # frozen_string_literal: true
require_relative "visibility_checking"
model_subclasses = []
[Sequel::Database, Sequel::Dataset, Sequel::Model, Sequel::Model.singleton_class].each do |c|
VISIBILITY_CHANGES.concat(VisibilityChecker.visibility_changes(c).map{|v| [v, c.inspect]})
end
Sequel::Model.singleton_class.class_... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/sequel_coverage.rb | Ruby | mit | 5,086 | master | 1,074 | # frozen_string_literal: true
require 'simplecov'
def SimpleCov.sequel_coverage(opts = {})
start do
enable_coverage :branch
command_name SEQUEL_COVERAGE unless SEQUEL_COVERAGE == "1"
add_filter{|f| f.filename.match(%r{\A#{Regexp.escape(File.dirname(__FILE__))}/})}
if ENV['SEQUEL_MERGE_COVERAGE']
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/deprecation_helper.rb | Ruby | mit | 5,086 | master | 713 | # frozen_string_literal: true
Sequel::Deprecation.backtrace_filter = lambda{|line, lineno| lineno < 4 || line =~ /_spec\.rb/}
class Minitest::HooksSpec
def self.deprecated(a, &block)
it("#{a} (deprecated)") do
deprecated{instance_exec(&block)}
end
end
def deprecated
output = Sequel::Deprecatio... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/guards_helper.rb | Ruby | mit | 5,086 | master | 2,123 | # frozen_string_literal: true
ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
gem 'minitest'
require 'minitest/global_expectations/autorun'
require 'minitest/hooks/default'
require_relative "deprecation_helper"
def Sequel.guarded?(*checked)
unless ENV['SEQUEL_NO_PENDING']
checked.each do ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/visibility_checking.rb | Ruby | mit | 5,086 | master | 642 | # frozen_string_literal: true
require 'visibility_checker'
changes = VISIBILITY_CHANGES = []
Minitest.after_run do
if defined?(DB)
[DB.singleton_class, DB.dataset.singleton_class].each do |c|
VISIBILITY_CHANGES.concat(VisibilityChecker.visibility_changes(c).map{|v| [v, c.inspect]})
end
end
changes.... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/core_extensions_spec.rb | Ruby | mit | 5,086 | master | 31,754 | # frozen_string_literal: true
if ENV['COVERAGE']
require_relative "sequel_coverage"
SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/extensions/core_extensions\.rb\z})
end
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../lib/"))
require_relative '../lib/sequel'
Regexp.send(:include, Sequel::SQL:... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/async_spec_helper.rb | Ruby | mit | 5,086 | master | 751 | # frozen_string_literal: true
class Minitest::Spec
if ENV['SEQUEL_ASYNC_THREAD_POOL'] || ENV['SEQUEL_ASYNC_THREAD_POOL_PREEMPT'] || ENV['SEQUEL_EAGER_ASYNC']
use_async = true
if ENV['SEQUEL_ASYNC_THREAD_POOL_PREEMPT']
::DB.opts[:preempt_async_thread] = true
end
::DB.opts[:num_async_threads] = 12... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/paged_operations_spec.rb | Ruby | mit | 5,086 | master | 13,767 | # frozen_string_literal: true
require_relative "spec_helper"
describe "paged_operations plugin" do
before do
@db = Sequel.mock
@c = Class.new(Sequel::Model(@db[:albums]))
@c.plugin :paged_operations
@ds = @c.dataset
@db.sqls
@db.fetch = [[{:id=>1002}], [{:id=>2002}]]
@db.numrows = [1000, ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/pg_array_associations_spec.rb | Ruby | mit | 5,086 | master | 49,310 | # frozen_string_literal: true
require_relative "spec_helper"
describe Sequel::Model, "pg_array_associations" do
before do
@db = Sequel.mock(:host=>'postgres', :numrows=>1)
@db.extend_datasets{def quote_identifiers?; false end}
class ::Artist < Sequel::Model(@db)
attr_accessor :yyy
columns :id... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/def_dataset_method_spec.rb | Ruby | mit | 5,086 | master | 3,126 | # frozen_string_literal: true
require_relative "spec_helper"
describe Sequel::Model, ".def_dataset_method" do
before do
@c = Class.new(Sequel::Model(:items))
@c.plugin :def_dataset_method
end
it "should add a method to the dataset and model if called with a block argument" do
@c.def_dataset_method... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/primary_key_lookup_check_values_spec.rb | Ruby | mit | 5,086 | master | 8,196 | # frozen_string_literal: true
require_relative "spec_helper"
describe "primary_key_lookup_check_values plugin" do
int_pk_schema = {:id=>{:primary_key=>true, :type=>:integer, :min_value=>0, :max_value=>10}.freeze}.freeze
def model(schema)
fetch = {}
schema.keys.each_with_index{|k,i| fetch[k] = i+1}
db ... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/auto_validations_spec.rb | Ruby | mit | 5,086 | master | 12,576 | # frozen_string_literal: true
require_relative "spec_helper"
describe "Sequel::Plugins::AutoValidations" do
before do
fetch_proc = proc do |sql|
if sql =~ /'a{51}'|'uniq'/
sql =~ /1 AS one/ ? {:v=>nil} : {:v=>0}
else
{:v=>1}
end
end
db = Sequel.mock(:fetch=>fetch_proc)
... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/arbitrary_servers_spec.rb | Ruby | mit | 5,086 | master | 3,308 | # frozen_string_literal: true
require_relative "spec_helper"
describe "arbtirary servers" do
before do
@db = Sequel.mock(:servers=>{})
@db.extension :arbitrary_servers
end
it "should allow arbitrary server options using a hash" do
@db.synchronize(:host=>'host1', :database=>'db1') do |c|
c.opts... |
github | jeremyevans/sequel | https://github.com/jeremyevans/sequel | spec/extensions/pg_array_ops_spec.rb | Ruby | mit | 5,086 | master | 6,081 | # frozen_string_literal: true
require_relative "spec_helper"
Sequel.extension :pg_array, :pg_array_ops, :pg_hstore, :pg_hstore_ops
describe "Sequel::Postgres::ArrayOp" do
before do
@db = Sequel.connect('mock://postgres')
@db.extend_datasets{def quote_identifiers?; false end}
@a = Sequel.pg_array_op(:a)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.