sequel 5.107.0 → 5.108.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/sequel +5 -5
- data/lib/sequel/adapters/ado.rb +1 -1
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc.rb +2 -2
- data/lib/sequel/adapters/mock.rb +1 -1
- data/lib/sequel/adapters/mysql.rb +7 -2
- data/lib/sequel/adapters/mysql2.rb +5 -4
- data/lib/sequel/adapters/postgres.rb +37 -37
- data/lib/sequel/adapters/shared/db2.rb +2 -2
- data/lib/sequel/adapters/shared/mssql.rb +4 -4
- data/lib/sequel/adapters/shared/mysql.rb +2 -2
- data/lib/sequel/adapters/shared/postgres.rb +67 -44
- data/lib/sequel/adapters/shared/sqlite.rb +3 -3
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +1 -1
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +11 -1
- data/lib/sequel/connection_pool/sharded_single.rb +1 -1
- data/lib/sequel/connection_pool/sharded_threaded.rb +7 -5
- data/lib/sequel/connection_pool/sharded_timed_queue.rb +3 -3
- data/lib/sequel/connection_pool/threaded.rb +9 -7
- data/lib/sequel/connection_pool/timed_queue.rb +2 -2
- data/lib/sequel/connection_pool.rb +3 -3
- data/lib/sequel/core.rb +30 -22
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/features.rb +1 -1
- data/lib/sequel/database/misc.rb +7 -7
- data/lib/sequel/database/query.rb +2 -2
- data/lib/sequel/database/schema_generator.rb +4 -4
- data/lib/sequel/database/schema_methods.rb +2 -2
- data/lib/sequel/database/transactions.rb +4 -4
- data/lib/sequel/dataset/actions.rb +1 -1
- data/lib/sequel/dataset/features.rb +4 -4
- data/lib/sequel/dataset/graph.rb +1 -1
- data/lib/sequel/dataset/misc.rb +3 -3
- data/lib/sequel/dataset/prepared_statements.rb +2 -2
- data/lib/sequel/dataset/query.rb +8 -8
- data/lib/sequel/dataset/sql.rb +18 -10
- data/lib/sequel/dataset.rb +2 -2
- data/lib/sequel/deprecated.rb +2 -2
- data/lib/sequel/exceptions.rb +2 -2
- data/lib/sequel/extensions/_pretty_table.rb +1 -1
- data/lib/sequel/extensions/async_thread_pool.rb +3 -3
- data/lib/sequel/extensions/auto_cast_date_and_time.rb +2 -2
- data/lib/sequel/extensions/blank.rb +2 -2
- data/lib/sequel/extensions/constraint_validations.rb +1 -1
- data/lib/sequel/extensions/core_refinements.rb +8 -8
- data/lib/sequel/extensions/date_arithmetic.rb +1 -1
- data/lib/sequel/extensions/datetime_parse_to_time.rb +2 -2
- data/lib/sequel/extensions/duplicate_columns_handler.rb +2 -2
- data/lib/sequel/extensions/graph_each.rb +1 -1
- data/lib/sequel/extensions/index_caching.rb +1 -1
- data/lib/sequel/extensions/inflector.rb +5 -5
- data/lib/sequel/extensions/is_distinct_from.rb +2 -2
- data/lib/sequel/extensions/lit_require_frozen.rb +3 -3
- data/lib/sequel/extensions/migration.rb +21 -7
- data/lib/sequel/extensions/named_timezones.rb +8 -8
- data/lib/sequel/extensions/pg_array.rb +9 -8
- data/lib/sequel/extensions/pg_array_ops.rb +69 -14
- data/lib/sequel/extensions/pg_auto_parameterize.rb +2 -2
- data/lib/sequel/extensions/pg_auto_parameterize_in_array.rb +3 -3
- data/lib/sequel/extensions/pg_enum.rb +2 -2
- data/lib/sequel/extensions/pg_extended_date_support.rb +5 -5
- data/lib/sequel/extensions/pg_extended_integer_support.rb +1 -1
- data/lib/sequel/extensions/pg_hstore.rb +2 -2
- data/lib/sequel/extensions/pg_hstore_ops.rb +5 -5
- data/lib/sequel/extensions/pg_inet.rb +2 -2
- data/lib/sequel/extensions/pg_inet_ops.rb +2 -2
- data/lib/sequel/extensions/pg_interval.rb +6 -6
- data/lib/sequel/extensions/pg_json.rb +4 -4
- data/lib/sequel/extensions/pg_json_ops.rb +11 -11
- data/lib/sequel/extensions/pg_range.rb +6 -6
- data/lib/sequel/extensions/pg_range_ops.rb +7 -7
- data/lib/sequel/extensions/pg_row.rb +4 -4
- data/lib/sequel/extensions/pg_row_ops.rb +6 -6
- data/lib/sequel/extensions/provenance.rb +2 -2
- data/lib/sequel/extensions/query.rb +2 -2
- data/lib/sequel/extensions/s.rb +2 -2
- data/lib/sequel/extensions/schema_dumper.rb +4 -4
- data/lib/sequel/extensions/sequel_4_dataset_methods.rb +2 -0
- data/lib/sequel/extensions/sql_comments.rb +1 -1
- data/lib/sequel/extensions/sql_log_normalizer.rb +1 -1
- data/lib/sequel/extensions/sqlite_json_ops.rb +2 -2
- data/lib/sequel/extensions/string_agg.rb +5 -5
- data/lib/sequel/extensions/symbol_aref.rb +3 -3
- data/lib/sequel/extensions/symbol_aref_refinement.rb +3 -3
- data/lib/sequel/extensions/symbol_as_refinement.rb +2 -2
- data/lib/sequel/extensions/transaction_connection_validator.rb +1 -1
- data/lib/sequel/model/associations.rb +17 -17
- data/lib/sequel/model/base.rb +19 -11
- data/lib/sequel/model/inflections.rb +1 -1
- data/lib/sequel/model/plugins.rb +2 -2
- data/lib/sequel/model.rb +2 -2
- data/lib/sequel/plugins/association_pks.rb +1 -1
- data/lib/sequel/plugins/association_proxies.rb +4 -4
- data/lib/sequel/plugins/auto_restrict_eager_graph.rb +2 -0
- data/lib/sequel/plugins/caching.rb +1 -1
- data/lib/sequel/plugins/class_table_inheritance.rb +1 -1
- data/lib/sequel/plugins/column_encryption.rb +10 -10
- data/lib/sequel/plugins/concurrent_eager_loading.rb +2 -2
- data/lib/sequel/plugins/csv_serializer.rb +2 -2
- data/lib/sequel/plugins/deprecated_associations.rb +2 -2
- data/lib/sequel/plugins/eager_each.rb +1 -1
- data/lib/sequel/plugins/finder.rb +1 -1
- data/lib/sequel/plugins/forbid_lazy_load.rb +3 -3
- data/lib/sequel/plugins/insert_conflict.rb +1 -1
- data/lib/sequel/plugins/insert_returning_select.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +4 -4
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/many_through_many.rb +1 -1
- data/lib/sequel/plugins/pg_array_associations.rb +4 -4
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +3 -3
- data/lib/sequel/plugins/pg_eager_any_typed_array.rb +2 -2
- data/lib/sequel/plugins/prepared_statements.rb +2 -2
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
- data/lib/sequel/plugins/skip_saving_columns.rb +2 -2
- data/lib/sequel/plugins/split_values.rb +1 -1
- data/lib/sequel/plugins/sql_comments.rb +8 -8
- data/lib/sequel/plugins/subclasses.rb +6 -6
- data/lib/sequel/plugins/subset_conditions.rb +2 -2
- data/lib/sequel/plugins/tactical_eager_loading.rb +1 -1
- data/lib/sequel/plugins/throw_failures.rb +2 -2
- data/lib/sequel/plugins/unused_associations.rb +5 -5
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +2 -0
- data/lib/sequel/sql.rb +11 -11
- data/lib/sequel/version.rb +1 -1
- metadata +1 -1
data/lib/sequel/core.rb
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
# For a quicker introduction, see the {cheat sheet}[rdoc-ref:doc/cheat_sheet.rdoc].
|
|
27
27
|
module Sequel
|
|
28
28
|
@convert_two_digit_years = true
|
|
29
|
-
@datetime_class = Time
|
|
30
|
-
@split_symbols = false
|
|
29
|
+
@datetime_class = Time # SEQUEL6: Remove
|
|
30
|
+
@split_symbols = false # SEQUEL6: Remove
|
|
31
31
|
@single_threaded = false
|
|
32
32
|
|
|
33
33
|
# Mutex used to protect mutable data structures
|
|
@@ -36,7 +36,7 @@ module Sequel
|
|
|
36
36
|
# Frozen hash used as the default options hash for most options.
|
|
37
37
|
OPTS = {}.freeze
|
|
38
38
|
|
|
39
|
-
SPLIT_SYMBOL_CACHE = {}
|
|
39
|
+
SPLIT_SYMBOL_CACHE = {} # SEQUEL6: Remove
|
|
40
40
|
|
|
41
41
|
module SequelMethods
|
|
42
42
|
# Sequel converts two digit years in <tt>Date</tt>s and <tt>DateTime</tt>s by default,
|
|
@@ -56,6 +56,8 @@ module Sequel
|
|
|
56
56
|
# cases where they implement the same methods, they often implement them
|
|
57
57
|
# differently (e.g. + using seconds on +Time+ and days on +DateTime+).
|
|
58
58
|
attr_accessor :datetime_class
|
|
59
|
+
# SEQUEL6: Remove datetime_class=
|
|
60
|
+
# SEQUEL6.1: Remove datetime_class
|
|
59
61
|
|
|
60
62
|
# Set whether Sequel is being used in single threaded mode. By default,
|
|
61
63
|
# Sequel uses a thread-safe connection pool, which isn't as fast as the
|
|
@@ -66,8 +68,7 @@ module Sequel
|
|
|
66
68
|
# Sequel.single_threaded = true
|
|
67
69
|
attr_accessor :single_threaded
|
|
68
70
|
|
|
69
|
-
#
|
|
70
|
-
# require for backwards compatibility.
|
|
71
|
+
# # SEQUEL6: Remove
|
|
71
72
|
alias orig_require require
|
|
72
73
|
private :orig_require
|
|
73
74
|
|
|
@@ -169,14 +170,14 @@ module Sequel
|
|
|
169
170
|
def array_or_set_join(obj, arg)
|
|
170
171
|
obj.join(arg)
|
|
171
172
|
end
|
|
172
|
-
# :
|
|
173
|
+
# simplecov:disable
|
|
173
174
|
else
|
|
174
175
|
def array_or_set_join(obj, arg)
|
|
175
176
|
obj = obj.to_a if obj.is_a?(Set)
|
|
176
177
|
obj.join(arg)
|
|
177
178
|
end
|
|
178
179
|
end
|
|
179
|
-
# :
|
|
180
|
+
# simplecov:enable
|
|
180
181
|
|
|
181
182
|
if RUBY_VERSION >= '3.3'
|
|
182
183
|
# Create a new module using the block, and set the temporary name
|
|
@@ -185,13 +186,13 @@ module Sequel
|
|
|
185
186
|
mod.set_temporary_name(yield)
|
|
186
187
|
mod
|
|
187
188
|
end
|
|
188
|
-
# :
|
|
189
|
+
# simplecov:disable
|
|
189
190
|
else
|
|
190
191
|
def set_temp_name(mod)
|
|
191
192
|
mod
|
|
192
193
|
end
|
|
193
194
|
end
|
|
194
|
-
# :
|
|
195
|
+
# simplecov:enable
|
|
195
196
|
|
|
196
197
|
# Convert given object to json and return the result.
|
|
197
198
|
# This can be overridden to use an alternative json implementation.
|
|
@@ -231,18 +232,23 @@ module Sequel
|
|
|
231
232
|
|
|
232
233
|
# For backwards compatibility only. require_relative should be used instead.
|
|
233
234
|
def require(files, subdir=nil)
|
|
235
|
+
# SEQUEL6: Remove
|
|
234
236
|
# Use Kernel.require_relative to work around JRuby 9.0 bug
|
|
237
|
+
# simplecov:disable
|
|
235
238
|
Array(files).each{|f| Kernel.require_relative "#{"#{subdir}/" if subdir}#{f}"}
|
|
239
|
+
# simplecov:enable
|
|
240
|
+
Sequel::Deprecation.deprecate("Sequel.require is deprecated and will be removed in Sequel 6.")
|
|
236
241
|
end
|
|
237
242
|
|
|
238
243
|
# Splits the symbol into three parts, if symbol splitting is enabled (not the default).
|
|
239
244
|
# Each part will either be a string or nil. If symbol splitting
|
|
240
245
|
# is disabled, returns an array with the first and third parts
|
|
241
|
-
# being nil, and the second part
|
|
246
|
+
# being nil, and the second part behind a string version of the symbol.
|
|
242
247
|
#
|
|
243
248
|
# For columns, these parts are the table, column, and alias.
|
|
244
249
|
# For tables, these parts are the schema, table, and alias.
|
|
245
250
|
def split_symbol(sym)
|
|
251
|
+
# SEQUEL6.1: Remove
|
|
246
252
|
unless v = Sequel.synchronize{SPLIT_SYMBOL_CACHE[sym]}
|
|
247
253
|
if split_symbols?
|
|
248
254
|
v = case s = sym.to_s
|
|
@@ -284,7 +290,7 @@ module Sequel
|
|
|
284
290
|
#
|
|
285
291
|
# Disabling symbol splitting will also disable the handling
|
|
286
292
|
# of double underscores in virtual row methods, causing such methods to
|
|
287
|
-
# yield regular
|
|
293
|
+
# yield regular identifiers instead of qualified identifiers:
|
|
288
294
|
#
|
|
289
295
|
# # Sequel.split_symbols = true
|
|
290
296
|
# Sequel.expr{table__column} # table.column
|
|
@@ -294,12 +300,14 @@ module Sequel
|
|
|
294
300
|
# Sequel.expr{table__column} # table__column
|
|
295
301
|
# Sequel.expr{table[:column]} # table.column
|
|
296
302
|
def split_symbols=(v)
|
|
303
|
+
# SEQUEL6: Remove
|
|
297
304
|
Sequel.synchronize{SPLIT_SYMBOL_CACHE.clear}
|
|
298
305
|
@split_symbols = v
|
|
299
306
|
end
|
|
300
307
|
|
|
301
308
|
# Whether Sequel currently splits symbols into qualified/aliased identifiers.
|
|
302
309
|
def split_symbols?
|
|
310
|
+
# SEQUEL6.1: Remove
|
|
303
311
|
@split_symbols
|
|
304
312
|
end
|
|
305
313
|
|
|
@@ -352,11 +360,11 @@ module Sequel
|
|
|
352
360
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
353
361
|
end
|
|
354
362
|
else
|
|
355
|
-
# :
|
|
363
|
+
# simplecov:disable
|
|
356
364
|
def start_timer # :nodoc:
|
|
357
365
|
Time.now
|
|
358
366
|
end
|
|
359
|
-
# :
|
|
367
|
+
# simplecov:enable
|
|
360
368
|
end
|
|
361
369
|
|
|
362
370
|
# The elapsed seconds since the given timer object was created. The
|
|
@@ -451,15 +459,15 @@ module Sequel
|
|
|
451
459
|
end
|
|
452
460
|
extend SequelMethods
|
|
453
461
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
462
|
+
require_relative "deprecated"
|
|
463
|
+
require_relative "sql"
|
|
464
|
+
require_relative "connection_pool"
|
|
465
|
+
require_relative "exceptions"
|
|
466
|
+
require_relative "dataset"
|
|
467
|
+
require_relative "database"
|
|
468
|
+
require_relative "timezones"
|
|
469
|
+
require_relative "ast_transformer"
|
|
470
|
+
require_relative "version"
|
|
463
471
|
|
|
464
472
|
class << self
|
|
465
473
|
# Allow nicer syntax for creating Sequel expressions:
|
|
@@ -192,7 +192,7 @@ module Sequel
|
|
|
192
192
|
|
|
193
193
|
# Disconnects all available connections from the connection pool. Any
|
|
194
194
|
# connections currently in use will not be disconnected. Options:
|
|
195
|
-
# :server :: Should be a symbol
|
|
195
|
+
# :server :: Should be a symbol specifying the server to disconnect from,
|
|
196
196
|
# or an array of symbols to specify multiple servers.
|
|
197
197
|
#
|
|
198
198
|
# Example:
|
|
@@ -5,7 +5,7 @@ module Sequel
|
|
|
5
5
|
# ---------------------
|
|
6
6
|
# :section: 9 - Methods that describe what the database supports
|
|
7
7
|
# These methods all return booleans, with most describing whether or not the
|
|
8
|
-
# database
|
|
8
|
+
# database supports a given feature.
|
|
9
9
|
# ---------------------
|
|
10
10
|
|
|
11
11
|
# Whether the database uses a global namespace for the index, true by default. If
|
data/lib/sequel/database/misc.rb
CHANGED
|
@@ -26,9 +26,9 @@ module Sequel
|
|
|
26
26
|
:time=>Sequel::SQLTime, :boolean=>[TrueClass, FalseClass].freeze, :float=>Float, :decimal=>BigDecimal,
|
|
27
27
|
:blob=>Sequel::SQL::Blob}.freeze
|
|
28
28
|
|
|
29
|
-
# :
|
|
29
|
+
# simplecov:disable
|
|
30
30
|
URI_PARSER = defined?(::URI::RFC2396_PARSER) ? ::URI::RFC2396_PARSER : ::URI::DEFAULT_PARSER
|
|
31
|
-
# :
|
|
31
|
+
# simplecov:enable
|
|
32
32
|
private_constant :URI_PARSER
|
|
33
33
|
|
|
34
34
|
# Nested hook Proc; each new hook Proc just wraps the previous one.
|
|
@@ -98,7 +98,7 @@ module Sequel
|
|
|
98
98
|
# The options hash for this database
|
|
99
99
|
attr_reader :opts
|
|
100
100
|
|
|
101
|
-
# Set the timezone to use for this database,
|
|
101
|
+
# Set the timezone to use for this database, overriding <tt>Sequel.database_timezone</tt>.
|
|
102
102
|
attr_writer :timezone
|
|
103
103
|
|
|
104
104
|
# The specific default size of string columns for this Sequel::Database, usually 255 by default.
|
|
@@ -230,9 +230,9 @@ module Sequel
|
|
|
230
230
|
|
|
231
231
|
# Disallow dup/clone for Database instances
|
|
232
232
|
undef_method :dup, :clone, :initialize_copy
|
|
233
|
-
# :
|
|
233
|
+
# simplecov:disable
|
|
234
234
|
if RUBY_VERSION >= '1.9.3'
|
|
235
|
-
# :
|
|
235
|
+
# simplecov:enable
|
|
236
236
|
undef_method :initialize_clone, :initialize_dup
|
|
237
237
|
end
|
|
238
238
|
|
|
@@ -580,7 +580,7 @@ module Sequel
|
|
|
580
580
|
# Typecast a string to a BigDecimal
|
|
581
581
|
alias _typecast_value_string_to_decimal BigDecimal
|
|
582
582
|
else
|
|
583
|
-
# :
|
|
583
|
+
# simplecov:disable
|
|
584
584
|
def _typecast_value_string_to_decimal(value)
|
|
585
585
|
d = BigDecimal(value)
|
|
586
586
|
if d.zero?
|
|
@@ -595,7 +595,7 @@ module Sequel
|
|
|
595
595
|
end
|
|
596
596
|
d
|
|
597
597
|
end
|
|
598
|
-
# :
|
|
598
|
+
# simplecov:enable
|
|
599
599
|
end
|
|
600
600
|
|
|
601
601
|
# Typecast the value to a BigDecimal
|
|
@@ -415,9 +415,9 @@ module Sequel
|
|
|
415
415
|
|
|
416
416
|
# Post process the schema values.
|
|
417
417
|
def schema_post_process(cols)
|
|
418
|
-
# :
|
|
418
|
+
# simplecov:disable
|
|
419
419
|
if RUBY_VERSION >= '2.5'
|
|
420
|
-
# :
|
|
420
|
+
# simplecov:enable
|
|
421
421
|
cols.each do |_, h|
|
|
422
422
|
db_type = h[:db_type]
|
|
423
423
|
if db_type.is_a?(String)
|
|
@@ -13,9 +13,9 @@ module Sequel
|
|
|
13
13
|
def _merge_column_options(defaults, opts)
|
|
14
14
|
defaults.merge!(opts) do |k, defv, v|
|
|
15
15
|
unless defv == v
|
|
16
|
-
# :
|
|
16
|
+
# simplecov:disable
|
|
17
17
|
if RUBY_VERSION >= "3.2"
|
|
18
|
-
# :
|
|
18
|
+
# simplecov:enable
|
|
19
19
|
caller_loc = Thread.each_caller_location do |loc|
|
|
20
20
|
# Skip core library methods implemented in Ruby
|
|
21
21
|
path = loc.path
|
|
@@ -152,7 +152,7 @@ module Sequel
|
|
|
152
152
|
# :not_null :: Similar to setting <tt>null: false</tt>, but you can provide a hash value
|
|
153
153
|
# to specify options for the NOT NULL constraint on PostgreSQL 18+:
|
|
154
154
|
# :name :: The name of the NOT NULL constraint
|
|
155
|
-
# :no_inherit :: Set NO INHERIT on the constraint, so it will not
|
|
155
|
+
# :no_inherit :: Set NO INHERIT on the constraint, so it will not propagate to
|
|
156
156
|
# child tables.
|
|
157
157
|
# :null :: Mark the column as allowing NULL values (if true),
|
|
158
158
|
# or not allowing NULL values (if false). The default is to allow NULL values.
|
|
@@ -227,7 +227,7 @@ module Sequel
|
|
|
227
227
|
# :deferrable :: Whether the CHECK constraint should be marked DEFERRABLE.
|
|
228
228
|
#
|
|
229
229
|
# PostgreSQL specific options:
|
|
230
|
-
# :no_inherit :: Set NO INHERIT on the constraint, so it will not
|
|
230
|
+
# :no_inherit :: Set NO INHERIT on the constraint, so it will not propagate to
|
|
231
231
|
# child tables.
|
|
232
232
|
# :not_enforced :: Whether the CHECK constraint should be marked NOT ENFORCED.
|
|
233
233
|
# :not_valid :: Whether the CHECK constraint should be marked NOT VALID.
|
|
@@ -984,7 +984,7 @@ module Sequel
|
|
|
984
984
|
on_delete_clause(action)
|
|
985
985
|
end
|
|
986
986
|
|
|
987
|
-
# Add fragment for primary key specification, separated for easier
|
|
987
|
+
# Add fragment for primary key specification, separated for easier overriding.
|
|
988
988
|
def primary_key_constraint_sql_fragment(_)
|
|
989
989
|
'PRIMARY KEY'
|
|
990
990
|
end
|
|
@@ -1144,7 +1144,7 @@ module Sequel
|
|
|
1144
1144
|
"#{type}#{literal(Array(elements)) if elements}#{' UNSIGNED' if column[:unsigned]}"
|
|
1145
1145
|
end
|
|
1146
1146
|
|
|
1147
|
-
# Add fragment for unique specification, separated for easier
|
|
1147
|
+
# Add fragment for unique specification, separated for easier overriding.
|
|
1148
1148
|
def unique_constraint_sql_fragment(_)
|
|
1149
1149
|
'UNIQUE'
|
|
1150
1150
|
end
|
|
@@ -50,7 +50,7 @@ module Sequel
|
|
|
50
50
|
# Options:
|
|
51
51
|
# :savepoint :: If currently inside a savepoint, run this hook immediately when
|
|
52
52
|
# any enclosing savepoint is rolled back, which may be before the transaction
|
|
53
|
-
# commits or
|
|
53
|
+
# commits or rolls back.
|
|
54
54
|
# :server :: The server/shard to use.
|
|
55
55
|
def after_rollback(opts=OPTS, &block)
|
|
56
56
|
raise Error, "must provide block to after_rollback" unless block
|
|
@@ -69,7 +69,7 @@ module Sequel
|
|
|
69
69
|
# When exiting the transaction block through methods other than an exception
|
|
70
70
|
# (e.g. normal exit, non-local return, or throw), set the current transaction
|
|
71
71
|
# to rollback instead of committing. This is designed for use in cases where
|
|
72
|
-
# you want to
|
|
72
|
+
# you want to perform a non-local return but also want to rollback instead of
|
|
73
73
|
# committing.
|
|
74
74
|
# Options:
|
|
75
75
|
# :cancel :: Cancel the current rollback_on_exit setting, so exiting will commit instead
|
|
@@ -246,7 +246,7 @@ module Sequel
|
|
|
246
246
|
# Internal generic transaction method. Any exception raised by the given
|
|
247
247
|
# block will cause the transaction to be rolled back. If the exception is
|
|
248
248
|
# not a Sequel::Rollback, the error will be reraised. If no exception occurs
|
|
249
|
-
# inside the block, the transaction is
|
|
249
|
+
# inside the block, the transaction is committed.
|
|
250
250
|
def _transaction(conn, opts=OPTS)
|
|
251
251
|
rollback = opts[:rollback]
|
|
252
252
|
begin
|
|
@@ -538,7 +538,7 @@ module Sequel
|
|
|
538
538
|
end
|
|
539
539
|
|
|
540
540
|
# Finish a subtransaction. If savepoints are supported, pops the current
|
|
541
|
-
#
|
|
541
|
+
# transaction off the savepoint stack.
|
|
542
542
|
def transaction_finished?(conn)
|
|
543
543
|
if supports_savepoints?
|
|
544
544
|
stack = _trans(conn)[:savepoints]
|
|
@@ -1343,7 +1343,7 @@ module Sequel
|
|
|
1343
1343
|
Sequel.|(*cond)
|
|
1344
1344
|
end
|
|
1345
1345
|
|
|
1346
|
-
# Downcase identifiers by default when
|
|
1346
|
+
# Downcase identifiers by default when outputting them from the database.
|
|
1347
1347
|
def output_identifier(v)
|
|
1348
1348
|
v = 'untitled' if v == ''
|
|
1349
1349
|
v.to_s.downcase.to_sym
|
|
@@ -25,7 +25,7 @@ module Sequel
|
|
|
25
25
|
false
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
# :
|
|
28
|
+
# simplecov:disable
|
|
29
29
|
|
|
30
30
|
# Whether the dataset requires SQL standard datetimes. False by default,
|
|
31
31
|
# as most allow strings with ISO 8601 format. Only for backwards compatibility,
|
|
@@ -34,7 +34,7 @@ module Sequel
|
|
|
34
34
|
# SEQUEL6: Remove
|
|
35
35
|
false
|
|
36
36
|
end
|
|
37
|
-
# :
|
|
37
|
+
# simplecov:enable
|
|
38
38
|
|
|
39
39
|
# Whether type specifiers are required for prepared statement/bound
|
|
40
40
|
# variable argument placeholders (i.e. :bv__integer), false by default.
|
|
@@ -188,14 +188,14 @@ module Sequel
|
|
|
188
188
|
true
|
|
189
189
|
end
|
|
190
190
|
|
|
191
|
-
# :
|
|
191
|
+
# simplecov:disable
|
|
192
192
|
|
|
193
193
|
# Whether the dataset supports timezones in literal timestamps, false by default.
|
|
194
194
|
def supports_timestamp_timezones?
|
|
195
195
|
# SEQUEL6: Remove
|
|
196
196
|
false
|
|
197
197
|
end
|
|
198
|
-
# :
|
|
198
|
+
# simplecov:enable
|
|
199
199
|
|
|
200
200
|
# Whether the dataset supports fractional seconds in literal timestamps, true by default.
|
|
201
201
|
def supports_timestamp_usecs?
|
data/lib/sequel/dataset/graph.rb
CHANGED
|
@@ -165,7 +165,7 @@ module Sequel
|
|
|
165
165
|
# columns in the subselect, qualified by the subselect alias.
|
|
166
166
|
Sequel.qualify(qualifier, Sequel.identifier(column))
|
|
167
167
|
else
|
|
168
|
-
# Initial dataset not wrapped in
|
|
168
|
+
# Initial dataset not wrapped in subselect, just make
|
|
169
169
|
# sure columns are qualified in some way.
|
|
170
170
|
qualified_expression(sel, qualifier)
|
|
171
171
|
end
|
data/lib/sequel/dataset/misc.rb
CHANGED
|
@@ -76,7 +76,7 @@ module Sequel
|
|
|
76
76
|
super
|
|
77
77
|
end
|
|
78
78
|
else
|
|
79
|
-
# :
|
|
79
|
+
# simplecov:disable
|
|
80
80
|
def freeze # :nodoc:
|
|
81
81
|
self
|
|
82
82
|
end
|
|
@@ -84,7 +84,7 @@ module Sequel
|
|
|
84
84
|
def frozen? # :nodoc:
|
|
85
85
|
true
|
|
86
86
|
end
|
|
87
|
-
# :
|
|
87
|
+
# simplecov:enable
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# Alias of +first_source_alias+
|
|
@@ -259,7 +259,7 @@ module Sequel
|
|
|
259
259
|
# underscore are reserved for internal use.
|
|
260
260
|
attr_reader :cache
|
|
261
261
|
|
|
262
|
-
#
|
|
262
|
+
# Retrieve a value from the dataset's cache in a thread safe manner.
|
|
263
263
|
def cache_get(k)
|
|
264
264
|
Sequel.synchronize{@cache[k]}
|
|
265
265
|
end
|
|
@@ -206,9 +206,9 @@ module Sequel
|
|
|
206
206
|
when :insert_pk, :single_value
|
|
207
207
|
with_sql_single_value(prepared_sql)
|
|
208
208
|
when Array
|
|
209
|
-
# :
|
|
209
|
+
# simplecov:disable
|
|
210
210
|
case type[0]
|
|
211
|
-
# :
|
|
211
|
+
# simplecov:enable
|
|
212
212
|
when :map, :as_hash, :to_hash, :to_hash_groups
|
|
213
213
|
force_prepared_sql.public_send(*type, &block)
|
|
214
214
|
end
|
data/lib/sequel/dataset/query.rb
CHANGED
|
@@ -98,7 +98,7 @@ module Sequel
|
|
|
98
98
|
c.freeze
|
|
99
99
|
end
|
|
100
100
|
else
|
|
101
|
-
# :
|
|
101
|
+
# simplecov:disable
|
|
102
102
|
def clone(opts = OPTS) # :nodoc:
|
|
103
103
|
c = super()
|
|
104
104
|
c.opts.merge!(opts)
|
|
@@ -108,7 +108,7 @@ module Sequel
|
|
|
108
108
|
c.opts.freeze
|
|
109
109
|
c
|
|
110
110
|
end
|
|
111
|
-
# :
|
|
111
|
+
# simplecov:enable
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
# Returns a copy of the dataset with the SQL DISTINCT clause. The DISTINCT
|
|
@@ -213,13 +213,13 @@ module Sequel
|
|
|
213
213
|
end
|
|
214
214
|
end
|
|
215
215
|
else
|
|
216
|
-
# :
|
|
216
|
+
# simplecov:disable
|
|
217
217
|
def extension(*exts) # :nodoc:
|
|
218
218
|
c = clone
|
|
219
219
|
c.send(:_extension!, exts)
|
|
220
220
|
c
|
|
221
221
|
end
|
|
222
|
-
# :
|
|
222
|
+
# simplecov:enable
|
|
223
223
|
end
|
|
224
224
|
|
|
225
225
|
# Alias for where.
|
|
@@ -1250,14 +1250,14 @@ module Sequel
|
|
|
1250
1250
|
o.freeze
|
|
1251
1251
|
end
|
|
1252
1252
|
else
|
|
1253
|
-
# :
|
|
1253
|
+
# simplecov:disable
|
|
1254
1254
|
def with_extend(*mods, &block) # :nodoc:
|
|
1255
1255
|
c = clone
|
|
1256
1256
|
c.extend(*mods) unless mods.empty?
|
|
1257
1257
|
c.extend(DatasetModule.new(&block)) if block
|
|
1258
1258
|
c
|
|
1259
1259
|
end
|
|
1260
|
-
# :
|
|
1260
|
+
# simplecov:enable
|
|
1261
1261
|
end
|
|
1262
1262
|
|
|
1263
1263
|
# Returns a cloned dataset with the given row_proc.
|
|
@@ -1354,7 +1354,7 @@ module Sequel
|
|
|
1354
1354
|
|
|
1355
1355
|
private
|
|
1356
1356
|
|
|
1357
|
-
# :
|
|
1357
|
+
# simplecov:disable
|
|
1358
1358
|
unless TRUE_FREEZE
|
|
1359
1359
|
# Load the extensions into the receiver, without checking if the receiver is frozen.
|
|
1360
1360
|
def _extension!(exts)
|
|
@@ -1373,7 +1373,7 @@ module Sequel
|
|
|
1373
1373
|
self
|
|
1374
1374
|
end
|
|
1375
1375
|
end
|
|
1376
|
-
# :
|
|
1376
|
+
# simplecov:enable
|
|
1377
1377
|
|
|
1378
1378
|
# A frozen array for the currently selected columns.
|
|
1379
1379
|
def _current_select(allow_plain_wildcard)
|
data/lib/sequel/dataset/sql.rb
CHANGED
|
@@ -1022,11 +1022,19 @@ module Sequel
|
|
|
1022
1022
|
# order if not. Also removes the row_proc, which isn't needed
|
|
1023
1023
|
# for aggregate calculations.
|
|
1024
1024
|
def aggregate_dataset
|
|
1025
|
-
(
|
|
1025
|
+
(aggregate_dataset_use_from_self? ? from_self : unordered).naked
|
|
1026
|
+
end
|
|
1027
|
+
|
|
1028
|
+
def aggreate_dataset_use_from_self? # :nodoc:
|
|
1029
|
+
# SEQUEL6: Remove
|
|
1030
|
+
# simplecov:disable
|
|
1031
|
+
Sequel::Deprecation.deprecate("Dataset#aggreate_dataset_use_from_self", "Use #aggregate_dataset_use_from_self? instead")
|
|
1032
|
+
aggregate_dataset_use_from_self?
|
|
1033
|
+
# simplecov:enable
|
|
1026
1034
|
end
|
|
1027
1035
|
|
|
1028
1036
|
# Whether to use from_self for an aggregate dataset.
|
|
1029
|
-
def
|
|
1037
|
+
def aggregate_dataset_use_from_self?
|
|
1030
1038
|
options_overlap(COUNT_FROM_SELF_OPTS)
|
|
1031
1039
|
end
|
|
1032
1040
|
|
|
@@ -1120,9 +1128,9 @@ module Sequel
|
|
|
1120
1128
|
# operators unsupported by some databases. Used by adapters for databases
|
|
1121
1129
|
# that don't support the operators natively.
|
|
1122
1130
|
def complex_expression_emulate_append(sql, op, args)
|
|
1123
|
-
# :
|
|
1131
|
+
# simplecov:disable
|
|
1124
1132
|
case op
|
|
1125
|
-
# :
|
|
1133
|
+
# simplecov:enable
|
|
1126
1134
|
when :%
|
|
1127
1135
|
complex_expression_arg_pairs_append(sql, args){|a, b| Sequel.function(:MOD, a, b)}
|
|
1128
1136
|
when :>>
|
|
@@ -1204,7 +1212,7 @@ module Sequel
|
|
|
1204
1212
|
end
|
|
1205
1213
|
end
|
|
1206
1214
|
|
|
1207
|
-
# Append literalization of array of grouping elements to SQL string,
|
|
1215
|
+
# Append literalization of array of grouping elements to SQL string, separating them with commas.
|
|
1208
1216
|
def grouping_element_list_append(sql, columns)
|
|
1209
1217
|
c = false
|
|
1210
1218
|
co = ', '
|
|
@@ -1229,7 +1237,7 @@ module Sequel
|
|
|
1229
1237
|
db.from_application_timestamp(v).strftime(default_timestamp_format)
|
|
1230
1238
|
end
|
|
1231
1239
|
|
|
1232
|
-
# :
|
|
1240
|
+
# simplecov:disable
|
|
1233
1241
|
|
|
1234
1242
|
# Return the SQL timestamp fragment to use for the fractional time part.
|
|
1235
1243
|
# Should start with the decimal point. Uses 6 decimal places by default.
|
|
@@ -1240,7 +1248,7 @@ module Sequel
|
|
|
1240
1248
|
end
|
|
1241
1249
|
sprintf(".%0#{ts}d", usec)
|
|
1242
1250
|
end
|
|
1243
|
-
# :
|
|
1251
|
+
# simplecov:enable
|
|
1244
1252
|
|
|
1245
1253
|
# Append literalization of identifier to SQL string, considering regular strings
|
|
1246
1254
|
# as SQL identifiers instead of SQL strings.
|
|
@@ -1372,7 +1380,7 @@ module Sequel
|
|
|
1372
1380
|
literal_string_append(sql, v)
|
|
1373
1381
|
end
|
|
1374
1382
|
|
|
1375
|
-
# Append literalization of dataset to SQL string. Does a subselect inside
|
|
1383
|
+
# Append literalization of dataset to SQL string. Does a subselect inside parentheses.
|
|
1376
1384
|
def literal_dataset_append(sql, v)
|
|
1377
1385
|
sql << 'LATERAL ' if v.opts[:lateral]
|
|
1378
1386
|
sql << '('
|
|
@@ -1438,7 +1446,7 @@ module Sequel
|
|
|
1438
1446
|
# Append a literalization of the object to the given SQL string.
|
|
1439
1447
|
# Calls +sql_literal_append+ if object responds to it, otherwise
|
|
1440
1448
|
# calls +sql_literal+ if object responds to it, otherwise raises an error.
|
|
1441
|
-
# If a database specific type is allowed, this should be
|
|
1449
|
+
# If a database specific type is allowed, this should be overridden in a subclass.
|
|
1442
1450
|
def literal_other_append(sql, v)
|
|
1443
1451
|
if v.respond_to?(:sql_literal_append)
|
|
1444
1452
|
v.sql_literal_append(self, sql)
|
|
@@ -1559,7 +1567,7 @@ module Sequel
|
|
|
1559
1567
|
end
|
|
1560
1568
|
|
|
1561
1569
|
# Modify the sql to add a dataset to the via an EXCEPT, INTERSECT, or UNION clause.
|
|
1562
|
-
# This uses a subselect for the compound datasets used, because using
|
|
1570
|
+
# This uses a subselect for the compound datasets used, because using parentheses doesn't
|
|
1563
1571
|
# work on all databases.
|
|
1564
1572
|
def select_compounds_sql(sql)
|
|
1565
1573
|
return unless c = @opts[:compounds]
|
data/lib/sequel/dataset.rb
CHANGED
|
@@ -54,7 +54,7 @@ module Sequel
|
|
|
54
54
|
require_relative "dataset/placeholder_literalizer"
|
|
55
55
|
require_relative "dataset/dataset_module"
|
|
56
56
|
|
|
57
|
-
# :
|
|
57
|
+
# simplecov:disable
|
|
58
58
|
require_relative "dataset/deprecated_singleton_class_methods" if Dataset::TRUE_FREEZE
|
|
59
|
-
# :
|
|
59
|
+
# simplecov:enable
|
|
60
60
|
end
|
data/lib/sequel/deprecated.rb
CHANGED
|
@@ -60,9 +60,9 @@ module Sequel
|
|
|
60
60
|
# If using ruby 2.3+, use Module#deprecate_constant to deprecate the constant,
|
|
61
61
|
# otherwise do nothing as the ruby implementation does not support constant deprecation.
|
|
62
62
|
def self.deprecate_constant(mod, constant)
|
|
63
|
-
# :
|
|
63
|
+
# simplecov:disable
|
|
64
64
|
if RUBY_VERSION > '2.3'
|
|
65
|
-
# :
|
|
65
|
+
# simplecov:enable
|
|
66
66
|
mod.deprecate_constant(constant)
|
|
67
67
|
end
|
|
68
68
|
end
|
data/lib/sequel/exceptions.rb
CHANGED
|
@@ -8,9 +8,9 @@ module Sequel
|
|
|
8
8
|
# exception is held here.
|
|
9
9
|
attr_accessor :wrapped_exception
|
|
10
10
|
|
|
11
|
-
# :
|
|
11
|
+
# simplecov:disable
|
|
12
12
|
if RUBY_VERSION >= '2.1'
|
|
13
|
-
# :
|
|
13
|
+
# simplecov:enable
|
|
14
14
|
# Returned the wrapped exception if one exists, otherwise use
|
|
15
15
|
# ruby's default behavior.
|
|
16
16
|
def cause
|
|
@@ -74,7 +74,7 @@ module Sequel
|
|
|
74
74
|
String.new << '|' << columns.map {|c| "%-#{sizes[c]}s" % c.to_s}.join('|') << '|'
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
# String for
|
|
77
|
+
# String for separator line
|
|
78
78
|
def self.separator_line(columns, sizes) # :nodoc:
|
|
79
79
|
String.new << '+' << columns.map {|c| '-' * sizes[c]}.join('+') << '+'
|
|
80
80
|
end
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
#
|
|
79
79
|
# # ...
|
|
80
80
|
# if result
|
|
81
|
-
# # will always execute this
|
|
81
|
+
# # will always execute this branch, since result is a proxy object
|
|
82
82
|
# end
|
|
83
83
|
#
|
|
84
84
|
# In this case, you can call the +__value+ method to return the actual
|
|
@@ -244,9 +244,9 @@ module Sequel
|
|
|
244
244
|
def method_missing(*args, &block)
|
|
245
245
|
__value.public_send(*args, &block)
|
|
246
246
|
end
|
|
247
|
-
# :
|
|
247
|
+
# simplecov:disable
|
|
248
248
|
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
|
249
|
-
# :
|
|
249
|
+
# simplecov:enable
|
|
250
250
|
|
|
251
251
|
# Delegate respond_to? calls to the returned result.
|
|
252
252
|
def respond_to_missing?(*args)
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
#
|
|
46
46
|
module Sequel
|
|
47
47
|
module AutoCastDateAndTime
|
|
48
|
-
# :
|
|
48
|
+
# simplecov:disable
|
|
49
49
|
|
|
50
50
|
# Mark the datasets as requiring sql standard date times. This is only needed
|
|
51
51
|
# for backwards compatibility.
|
|
@@ -53,7 +53,7 @@ module Sequel
|
|
|
53
53
|
# SEQUEL6: Remove
|
|
54
54
|
true
|
|
55
55
|
end
|
|
56
|
-
# :
|
|
56
|
+
# simplecov:enable
|
|
57
57
|
|
|
58
58
|
private
|
|
59
59
|
|