sequel 5.107.0 → 5.109.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/amalgalite.rb +34 -8
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
- data/lib/sequel/adapters/jdbc/mssql.rb +28 -5
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +14 -3
- data/lib/sequel/adapters/jdbc.rb +4 -3
- 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 +42 -39
- data/lib/sequel/adapters/shared/db2.rb +5 -2
- data/lib/sequel/adapters/shared/mssql.rb +11 -5
- data/lib/sequel/adapters/shared/mysql.rb +2 -2
- data/lib/sequel/adapters/shared/postgres.rb +80 -1028
- data/lib/sequel/adapters/shared/sqlanywhere.rb +0 -32
- data/lib/sequel/adapters/shared/sqlite.rb +3 -3
- data/lib/sequel/adapters/sqlite.rb +13 -9
- data/lib/sequel/adapters/trilogy.rb +2 -1
- 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 +44 -24
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/features.rb +1 -1
- data/lib/sequel/database/misc.rb +6 -11
- 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 +5 -7
- data/lib/sequel/dataset/actions.rb +2 -2
- 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 +32 -13
- 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 +7 -10
- 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 +1 -3
- 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 +20 -4
- data/lib/sequel/extensions/migration.rb +21 -7
- data/lib/sequel/extensions/named_timezones.rb +9 -9
- data/lib/sequel/extensions/pg_array.rb +10 -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 +15 -13
- 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 +6 -10
- data/lib/sequel/extensions/schema_dumper.rb +10 -6
- 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 +12 -32
- data/lib/sequel/extensions/symbol_aref_refinement.rb +2 -5
- data/lib/sequel/extensions/symbol_as.rb +1 -2
- data/lib/sequel/extensions/symbol_as_refinement.rb +1 -5
- data/lib/sequel/extensions/transaction_connection_validator.rb +1 -1
- data/lib/sequel/model/associations.rb +17 -17
- data/lib/sequel/model/base.rb +18 -15
- 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 +28 -3
- 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 +9 -20
- 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/instance_filters.rb +8 -0
- data/lib/sequel/plugins/instance_hooks.rb +19 -0
- 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/mssql_optimistic_locking.rb +9 -0
- data/lib/sequel/plugins/optimistic_locking.rb +12 -2
- data/lib/sequel/plugins/optimistic_locking_base.rb +14 -0
- 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/pg_xmin_optimistic_locking.rb +11 -2
- data/lib/sequel/plugins/prepared_statements.rb +2 -2
- data/lib/sequel/plugins/select_on_skipped_update.rb +63 -0
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +21 -3
- 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 +5 -16
- data/lib/sequel/plugins/tactical_eager_loading.rb +1 -1
- data/lib/sequel/plugins/throw_failures.rb +3 -3
- data/lib/sequel/plugins/unused_associations.rb +5 -5
- data/lib/sequel/plugins/validate_associated.rb +7 -1
- data/lib/sequel/plugins/validate_associated_context.rb +52 -0
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +2 -0
- data/lib/sequel/sql.rb +120 -116
- data/lib/sequel/version.rb +1 -1
- metadata +5 -3
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
# j.path_query_first_tz('$.foo') # jsonb_path_query_first_tz(jsonb_column, '$.foo')
|
|
104
104
|
#
|
|
105
105
|
# On PostgreSQL 14+, The JSONB <tt>[]</tt> method will use subscripts instead of being
|
|
106
|
-
# the same as +get+, if the value being wrapped is an
|
|
106
|
+
# the same as +get+, if the value being wrapped is an identifier:
|
|
107
107
|
#
|
|
108
108
|
# Sequel.pg_jsonb_op(:jsonb_column)[1] # jsonb_column[1]
|
|
109
109
|
# Sequel.pg_jsonb_op(:jsonb_column)[1][2] # jsonb_column[1][2]
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
#
|
|
174
174
|
# If you are also using the pg_json extension, you should load it before
|
|
175
175
|
# loading this extension. Doing so will allow you to use the #op method on
|
|
176
|
-
# JSONHash,
|
|
176
|
+
# JSONHash, JSONArray, JSONBHash, and JSONBArray, allowing you to perform json/jsonb operations
|
|
177
177
|
# on json/jsonb literals.
|
|
178
178
|
#
|
|
179
179
|
# In order to get the automatic conversion from a ruby array to a PostgreSQL array
|
|
@@ -843,9 +843,9 @@ module Sequel
|
|
|
843
843
|
|
|
844
844
|
# Wrap argument in a PGArray if it is an array or a set
|
|
845
845
|
def wrap_input_array(obj)
|
|
846
|
-
# :
|
|
846
|
+
# simplecov:disable
|
|
847
847
|
if Sequel.respond_to?(:pg_array)
|
|
848
|
-
# :
|
|
848
|
+
# simplecov:enable
|
|
849
849
|
case obj
|
|
850
850
|
when Array
|
|
851
851
|
return Sequel.pg_array(obj)
|
|
@@ -984,7 +984,8 @@ module Sequel
|
|
|
984
984
|
comma = true
|
|
985
985
|
end
|
|
986
986
|
ds.literal_append(sql, v)
|
|
987
|
-
sql << " AS "
|
|
987
|
+
sql << " AS "
|
|
988
|
+
ds.send(:identifier_append, sql, k)
|
|
988
989
|
end
|
|
989
990
|
end
|
|
990
991
|
end
|
|
@@ -1074,7 +1075,7 @@ module Sequel
|
|
|
1074
1075
|
end
|
|
1075
1076
|
end
|
|
1076
1077
|
|
|
1077
|
-
# Do not auto
|
|
1078
|
+
# Do not auto parameterize default value, as PostgreSQL doesn't allow it.
|
|
1078
1079
|
def default_literal_append(ds, sql, v)
|
|
1079
1080
|
if sql.respond_to?(:skip_auto_param)
|
|
1080
1081
|
sql.skip_auto_param do
|
|
@@ -1254,7 +1255,8 @@ module Sequel
|
|
|
1254
1255
|
comma = true
|
|
1255
1256
|
end
|
|
1256
1257
|
ds.literal_append(sql, v)
|
|
1257
|
-
sql << " AS "
|
|
1258
|
+
sql << " AS "
|
|
1259
|
+
ds.send(:identifier_append, sql, k)
|
|
1258
1260
|
end
|
|
1259
1261
|
end
|
|
1260
1262
|
|
|
@@ -1341,7 +1343,7 @@ module Sequel
|
|
|
1341
1343
|
end
|
|
1342
1344
|
end
|
|
1343
1345
|
|
|
1344
|
-
# Append path
|
|
1346
|
+
# Append path clause to the SQL
|
|
1345
1347
|
def to_s_append_path(ds, sql, path)
|
|
1346
1348
|
if path
|
|
1347
1349
|
sql << ' PATH '
|
|
@@ -1349,7 +1351,7 @@ module Sequel
|
|
|
1349
1351
|
end
|
|
1350
1352
|
end
|
|
1351
1353
|
|
|
1352
|
-
# Do not auto
|
|
1354
|
+
# Do not auto parameterize default value or path value, as PostgreSQL doesn't allow it.
|
|
1353
1355
|
def default_literal_append(ds, sql, v)
|
|
1354
1356
|
if sql.respond_to?(:skip_auto_param)
|
|
1355
1357
|
sql.skip_auto_param do
|
|
@@ -1375,9 +1377,9 @@ module Sequel
|
|
|
1375
1377
|
end
|
|
1376
1378
|
end
|
|
1377
1379
|
|
|
1378
|
-
# :
|
|
1380
|
+
# simplecov:disable
|
|
1379
1381
|
if defined?(JSONArray)
|
|
1380
|
-
# :
|
|
1382
|
+
# simplecov:enable
|
|
1381
1383
|
class JSONArray
|
|
1382
1384
|
# Wrap the JSONArray instance in an JSONOp, allowing you to easily use
|
|
1383
1385
|
# the PostgreSQL json functions and operators with literal jsons.
|
|
@@ -1443,7 +1445,7 @@ module Sequel
|
|
|
1443
1445
|
end
|
|
1444
1446
|
end
|
|
1445
1447
|
|
|
1446
|
-
# :
|
|
1448
|
+
# simplecov:disable
|
|
1447
1449
|
if Sequel.core_extensions?
|
|
1448
1450
|
class Symbol
|
|
1449
1451
|
include Sequel::Postgres::JSONOpMethods
|
|
@@ -1457,4 +1459,4 @@ if defined?(Sequel::CoreRefinements)
|
|
|
1457
1459
|
end
|
|
1458
1460
|
end
|
|
1459
1461
|
end
|
|
1460
|
-
# :
|
|
1462
|
+
# simplecov:enable
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
#
|
|
3
3
|
# The pg_range extension adds support for the PostgreSQL 9.2+ range
|
|
4
4
|
# types to Sequel. PostgreSQL range types are similar to ruby's
|
|
5
|
-
# Range class,
|
|
5
|
+
# Range class, representing an array of values. However, they
|
|
6
6
|
# are more flexible than ruby's ranges, allowing exclusive beginnings
|
|
7
7
|
# and endings (ruby's range only allows exclusive endings).
|
|
8
8
|
#
|
|
9
|
-
# When PostgreSQL range values are
|
|
9
|
+
# When PostgreSQL range values are retrieved, they are parsed and returned
|
|
10
10
|
# as instances of Sequel::Postgres::PGRange. PGRange mostly acts
|
|
11
11
|
# like a Range, but it's not a Range as not all PostgreSQL range
|
|
12
12
|
# type values would be valid ruby ranges. If the range type value
|
|
@@ -459,10 +459,10 @@ module Sequel
|
|
|
459
459
|
return @range if @range
|
|
460
460
|
raise(Error, "cannot create ruby range for an empty PostgreSQL range") if empty?
|
|
461
461
|
raise(Error, "cannot create ruby range when PostgreSQL range excludes beginning element") if exclude_begin?
|
|
462
|
-
# :
|
|
462
|
+
# simplecov:disable
|
|
463
463
|
raise(Error, "cannot create ruby range when PostgreSQL range has unbounded beginning") if STARTLESS_RANGE_NOT_SUPPORTED && !self.begin
|
|
464
464
|
raise(Error, "cannot create ruby range when PostgreSQL range has unbounded ending") if ENDLESS_RANGE_NOT_SUPPORTED && !self.end
|
|
465
|
-
# :
|
|
465
|
+
# simplecov:enable
|
|
466
466
|
@range = Range.new(self.begin, self.end, exclude_end?)
|
|
467
467
|
end
|
|
468
468
|
|
|
@@ -549,7 +549,7 @@ module Sequel
|
|
|
549
549
|
Database.register_extension(:pg_range, Postgres::PGRange::DatabaseMethods)
|
|
550
550
|
end
|
|
551
551
|
|
|
552
|
-
# :
|
|
552
|
+
# simplecov:disable
|
|
553
553
|
if Sequel.core_extensions?
|
|
554
554
|
class Range
|
|
555
555
|
# Create a new PGRange using the receiver as the input range,
|
|
@@ -569,4 +569,4 @@ if defined?(Sequel::CoreRefinements)
|
|
|
569
569
|
end
|
|
570
570
|
end
|
|
571
571
|
end
|
|
572
|
-
# :
|
|
572
|
+
# simplecov:enable
|
|
@@ -113,7 +113,7 @@ module Sequel
|
|
|
113
113
|
|
|
114
114
|
private
|
|
115
115
|
|
|
116
|
-
# Create a
|
|
116
|
+
# Create a boolean expression for the given type and argument.
|
|
117
117
|
def operator(type, other)
|
|
118
118
|
Sequel::SQL::BooleanExpression.new(:NOOP, Sequel::SQL::PlaceholderLiteralString.new(OPERATORS[type], [value, other]))
|
|
119
119
|
end
|
|
@@ -132,9 +132,9 @@ module Sequel
|
|
|
132
132
|
end
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
-
# :
|
|
135
|
+
# simplecov:disable
|
|
136
136
|
if defined?(PGRange)
|
|
137
|
-
# :
|
|
137
|
+
# simplecov:enable
|
|
138
138
|
class PGRange
|
|
139
139
|
# Wrap the PGRange instance in an RangeOp, allowing you to easily use
|
|
140
140
|
# the PostgreSQL range functions and operators with literal ranges.
|
|
@@ -144,9 +144,9 @@ module Sequel
|
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
-
# :
|
|
147
|
+
# simplecov:disable
|
|
148
148
|
if defined?(PGMultiRange)
|
|
149
|
-
# :
|
|
149
|
+
# simplecov:enable
|
|
150
150
|
class PGMultiRange
|
|
151
151
|
# Wrap the PGRange instance in an RangeOp, allowing you to easily use
|
|
152
152
|
# the PostgreSQL range functions and operators with literal ranges.
|
|
@@ -178,7 +178,7 @@ module Sequel
|
|
|
178
178
|
end
|
|
179
179
|
end
|
|
180
180
|
|
|
181
|
-
# :
|
|
181
|
+
# simplecov:disable
|
|
182
182
|
if Sequel.core_extensions?
|
|
183
183
|
class Symbol
|
|
184
184
|
include Sequel::Postgres::RangeOpMethods
|
|
@@ -192,4 +192,4 @@ if defined?(Sequel::CoreRefinements)
|
|
|
192
192
|
end
|
|
193
193
|
end
|
|
194
194
|
end
|
|
195
|
-
# :
|
|
195
|
+
# simplecov:enable
|
|
@@ -247,9 +247,9 @@ module Sequel
|
|
|
247
247
|
if skip(/\)/)
|
|
248
248
|
values << nil
|
|
249
249
|
else
|
|
250
|
-
# :
|
|
250
|
+
# simplecov:disable
|
|
251
251
|
until eos?
|
|
252
|
-
# :
|
|
252
|
+
# simplecov:enable
|
|
253
253
|
if skip(/"/)
|
|
254
254
|
values << scan(/(\\.|""|[^"])*/).gsub(/\\(.)|"(")/, '\1\2')
|
|
255
255
|
skip(/"[,)]/)
|
|
@@ -563,7 +563,7 @@ module Sequel
|
|
|
563
563
|
Database.register_extension(:pg_row, Postgres::PGRow::DatabaseMethods)
|
|
564
564
|
end
|
|
565
565
|
|
|
566
|
-
# :
|
|
566
|
+
# simplecov:disable
|
|
567
567
|
if Sequel.core_extensions?
|
|
568
568
|
class Array
|
|
569
569
|
# Wraps the receiver in an anonymous Sequel::Postgres::PGRow::ArrayRow instance.
|
|
@@ -582,4 +582,4 @@ if defined?(Sequel::CoreRefinements)
|
|
|
582
582
|
end
|
|
583
583
|
end
|
|
584
584
|
end
|
|
585
|
-
# :
|
|
585
|
+
# simplecov:enable
|
|
@@ -159,9 +159,9 @@ module Sequel
|
|
|
159
159
|
end
|
|
160
160
|
end
|
|
161
161
|
|
|
162
|
-
# :
|
|
162
|
+
# simplecov:disable
|
|
163
163
|
if defined?(PGRow::ArrayRow)
|
|
164
|
-
# :
|
|
164
|
+
# simplecov:enable
|
|
165
165
|
class PGRow::ArrayRow
|
|
166
166
|
# Wrap the PGRow::ArrayRow instance in an PGRowOp, allowing you to easily use
|
|
167
167
|
# the PostgreSQL row functions and operators with literal rows.
|
|
@@ -171,9 +171,9 @@ module Sequel
|
|
|
171
171
|
end
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
# :
|
|
174
|
+
# simplecov:disable
|
|
175
175
|
if defined?(PGRow::HashRow)
|
|
176
|
-
# :
|
|
176
|
+
# simplecov:enable
|
|
177
177
|
class PGRow::HashRow
|
|
178
178
|
# Wrap the PGRow::ArrayRow instance in an PGRowOp, allowing you to easily use
|
|
179
179
|
# the PostgreSQL row functions and operators with literal rows.
|
|
@@ -200,7 +200,7 @@ module Sequel
|
|
|
200
200
|
end
|
|
201
201
|
end
|
|
202
202
|
|
|
203
|
-
# :
|
|
203
|
+
# simplecov:disable
|
|
204
204
|
if Sequel.core_extensions?
|
|
205
205
|
class Symbol
|
|
206
206
|
include Sequel::Postgres::PGRowOp::ExpressionMethods
|
|
@@ -214,4 +214,4 @@ if defined?(Sequel::CoreRefinements)
|
|
|
214
214
|
end
|
|
215
215
|
end
|
|
216
216
|
end
|
|
217
|
-
# :
|
|
217
|
+
# simplecov:enable
|
|
@@ -46,11 +46,11 @@ module Sequel
|
|
|
46
46
|
super(provenance_opts(opts))
|
|
47
47
|
end
|
|
48
48
|
else
|
|
49
|
-
# :
|
|
49
|
+
# simplecov:disable
|
|
50
50
|
def clone(opts = OPTS) # :nodoc:
|
|
51
51
|
super(provenance_opts(opts))
|
|
52
52
|
end
|
|
53
|
-
# :
|
|
53
|
+
# simplecov:enable
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
%w'select insert update delete'.each do |type|
|
|
@@ -74,9 +74,9 @@ module Sequel
|
|
|
74
74
|
raise(Sequel::Error, "method #{method.inspect} did not return a dataset") unless @dataset.is_a?(Dataset)
|
|
75
75
|
self
|
|
76
76
|
end
|
|
77
|
-
# :
|
|
77
|
+
# simplecov:disable
|
|
78
78
|
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
|
79
|
-
# :
|
|
79
|
+
# simplecov:enable
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
data/lib/sequel/extensions/s.rb
CHANGED
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
#
|
|
30
30
|
# Object.send(:include, Sequel::S)
|
|
31
31
|
#
|
|
32
|
-
#
|
|
33
|
-
# can use Sequel::S as a refinement, in which case the private #S method
|
|
32
|
+
# You can use also Sequel::S as a refinement, in which case the private #S method
|
|
34
33
|
# will be available on all objects while the refinement is active.
|
|
35
34
|
#
|
|
36
35
|
# using Sequel::S
|
|
@@ -39,7 +38,6 @@
|
|
|
39
38
|
#
|
|
40
39
|
# Related module: Sequel::S
|
|
41
40
|
|
|
42
|
-
|
|
43
41
|
#
|
|
44
42
|
module Sequel::S
|
|
45
43
|
private
|
|
@@ -49,12 +47,10 @@ module Sequel::S
|
|
|
49
47
|
Sequel.expr(*a, &block)
|
|
50
48
|
end
|
|
51
49
|
|
|
52
|
-
# :
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
send include_meth, Sequel::S
|
|
58
|
-
end
|
|
50
|
+
# simplecov:disable
|
|
51
|
+
include_meth = RUBY_VERSION >= '3.1' ? :import_methods : :include
|
|
52
|
+
# simplecov:enable
|
|
53
|
+
refine Object do
|
|
54
|
+
send include_meth, Sequel::S
|
|
59
55
|
end
|
|
60
56
|
end
|
|
@@ -27,9 +27,9 @@ Sequel.extension :eval_inspect
|
|
|
27
27
|
|
|
28
28
|
module Sequel
|
|
29
29
|
module SchemaDumper
|
|
30
|
-
# :
|
|
30
|
+
# simplecov:disable
|
|
31
31
|
IGNORE_INDEX_ERRORS_KEY = RUBY_VERSION >= '3.4' ? 'ignore_index_errors: ' : ':ignore_index_errors=>'
|
|
32
|
-
# :
|
|
32
|
+
# simplecov:enable
|
|
33
33
|
private_constant :IGNORE_INDEX_ERRORS_KEY
|
|
34
34
|
|
|
35
35
|
# Convert the column schema information to a hash of column options, one of which must
|
|
@@ -200,8 +200,12 @@ END_MIG
|
|
|
200
200
|
|
|
201
201
|
# Recreate the column in the passed Schema::CreateTableGenerator from the given name and parsed database schema.
|
|
202
202
|
def recreate_column(name, schema, gen, options)
|
|
203
|
+
db_type = schema[:db_type]
|
|
204
|
+
db_type = literal(db_type) if options[:same_db] && database_type == :sqlite
|
|
205
|
+
|
|
203
206
|
if options[:single_pk] && schema_autoincrementing_primary_key?(schema)
|
|
204
|
-
type_hash = options[:same_db] ? {:type=>
|
|
207
|
+
type_hash = options[:same_db] ? {:type=>db_type} : column_schema_to_ruby_type(schema)
|
|
208
|
+
|
|
205
209
|
[:table, :key, :on_delete, :on_update, :deferrable].each{|f| type_hash[f] = schema[f] if schema[f]}
|
|
206
210
|
if type_hash == {:type=>Integer} || type_hash == {:type=>"integer"} || type_hash == {:type=>"INTEGER"}
|
|
207
211
|
type_hash.delete(:type)
|
|
@@ -220,7 +224,7 @@ END_MIG
|
|
|
220
224
|
end
|
|
221
225
|
else
|
|
222
226
|
col_opts = if options[:same_db]
|
|
223
|
-
h = {:type=>
|
|
227
|
+
h = {:type=>db_type}
|
|
224
228
|
if database_type == :mysql && h[:type].start_with?("timestamp")
|
|
225
229
|
h[:null] = true
|
|
226
230
|
end
|
|
@@ -430,10 +434,10 @@ END_MIG
|
|
|
430
434
|
|
|
431
435
|
module Schema
|
|
432
436
|
class CreateTableGenerator
|
|
433
|
-
# :
|
|
437
|
+
# simplecov:disable
|
|
434
438
|
DEFAULT_KEY = RUBY_VERSION >= '3.4' ? 'default: ' : ':default=>'
|
|
435
439
|
IGNORE_ERRORS_KEY = RUBY_VERSION >= '3.4' ? 'ignore_errors: ' : ':ignore_errors=>'
|
|
436
|
-
# :
|
|
440
|
+
# simplecov:enable
|
|
437
441
|
private_constant :DEFAULT_KEY
|
|
438
442
|
private_constant :IGNORE_ERRORS_KEY
|
|
439
443
|
|
|
@@ -108,7 +108,7 @@ module Sequel
|
|
|
108
108
|
# injection.
|
|
109
109
|
#
|
|
110
110
|
# Additionally, due to the use of an SQL comment, if any
|
|
111
|
-
# SQL is
|
|
111
|
+
# SQL is appended to the query after the comment is added,
|
|
112
112
|
# it will become part of the comment unless it is preceded
|
|
113
113
|
# by a newline.
|
|
114
114
|
if sql.frozen?
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
# The normalization is done by scanning the SQL string being executed
|
|
15
15
|
# for literal strings and numbers, and replacing them with question
|
|
16
16
|
# marks. While this should work for all or almost all production queries,
|
|
17
|
-
# there are
|
|
17
|
+
# there are pathological queries that will not be handled correctly, such as
|
|
18
18
|
# the use of apostrophes in identifiers:
|
|
19
19
|
#
|
|
20
20
|
# DB[:"asf'bar"].where(a: 1, b: 'something').first
|
|
@@ -296,7 +296,7 @@ module Sequel
|
|
|
296
296
|
end
|
|
297
297
|
end
|
|
298
298
|
|
|
299
|
-
# :
|
|
299
|
+
# simplecov:disable
|
|
300
300
|
if Sequel.core_extensions?
|
|
301
301
|
class Symbol
|
|
302
302
|
include Sequel::SQLite::JSONOpMethods
|
|
@@ -310,4 +310,4 @@ if defined?(Sequel::CoreRefinements)
|
|
|
310
310
|
end
|
|
311
311
|
end
|
|
312
312
|
end
|
|
313
|
-
# :
|
|
313
|
+
# simplecov:enable
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen-string-literal: true
|
|
2
2
|
#
|
|
3
3
|
# The string_agg extension adds the ability to perform database-independent
|
|
4
|
-
# aggregate string
|
|
4
|
+
# aggregate string concatenation. For example, with a table like:
|
|
5
5
|
#
|
|
6
6
|
# c1 | c2
|
|
7
7
|
# ---+---
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
# # or:
|
|
29
29
|
# sa = Sequel.string_agg(:column_name, '-') # custom separator
|
|
30
30
|
#
|
|
31
|
-
# You can specify the order in which the
|
|
31
|
+
# You can specify the order in which the concatenation happens by
|
|
32
32
|
# calling +order+ on the expression:
|
|
33
33
|
#
|
|
34
34
|
# sa = Sequel.string_agg(:column_name).order(:other_column)
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
# select_group(:c1).
|
|
46
46
|
# select_append(Sequel.string_agg(:c2))
|
|
47
47
|
#
|
|
48
|
-
# This extension
|
|
48
|
+
# This extension currently supports the following databases:
|
|
49
49
|
#
|
|
50
50
|
# * PostgreSQL 9+
|
|
51
51
|
# * SQLAnywhere 12+
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
module Sequel
|
|
63
63
|
module SQL
|
|
64
64
|
module Builders
|
|
65
|
-
# Return a StringAgg expression for an aggregate string
|
|
65
|
+
# Return a StringAgg expression for an aggregate string concatenation.
|
|
66
66
|
def string_agg(*a)
|
|
67
67
|
StringAgg.new(*a)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
# The StringAgg class represents an aggregate string
|
|
71
|
+
# The StringAgg class represents an aggregate string concatenation.
|
|
72
72
|
class StringAgg < GenericExpression
|
|
73
73
|
include StringMethods
|
|
74
74
|
include StringConcatenationMethods
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen-string-literal: true
|
|
2
2
|
#
|
|
3
3
|
# The symbol_aref extension makes Symbol#[] support Symbol,
|
|
4
|
-
# Sequel::SQL::
|
|
4
|
+
# Sequel::SQL::Identifier, and Sequel::SQL::QualifiedIdentifier instances,
|
|
5
5
|
# returning appropriate Sequel::SQL::QualifiedIdentifier instances. It's
|
|
6
6
|
# designed as a shortcut so that instead of:
|
|
7
7
|
#
|
|
@@ -15,41 +15,21 @@
|
|
|
15
15
|
#
|
|
16
16
|
# Sequel.extension :symbol_aref
|
|
17
17
|
#
|
|
18
|
-
#
|
|
19
|
-
# is a refinement version of this in the symbol_aref_refinement extension.
|
|
18
|
+
# There is a refinement version of this in the symbol_aref_refinement extension.
|
|
20
19
|
#
|
|
21
20
|
# Related module: Sequel::SymbolAref
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
super
|
|
31
|
-
end
|
|
22
|
+
module Sequel::SymbolAref
|
|
23
|
+
def [](v)
|
|
24
|
+
case v
|
|
25
|
+
when Symbol, Sequel::SQL::Identifier, Sequel::SQL::QualifiedIdentifier
|
|
26
|
+
Sequel::SQL::QualifiedIdentifier.new(self, v)
|
|
27
|
+
else
|
|
28
|
+
super
|
|
32
29
|
end
|
|
33
30
|
end
|
|
31
|
+
end
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
# :nocov:
|
|
39
|
-
else
|
|
40
|
-
class Symbol
|
|
41
|
-
if method_defined?(:[])
|
|
42
|
-
alias_method :aref_before_sequel, :[]
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def [](v)
|
|
46
|
-
case v
|
|
47
|
-
when Symbol, Sequel::SQL::Identifier, Sequel::SQL::QualifiedIdentifier
|
|
48
|
-
Sequel::SQL::QualifiedIdentifier.new(self, v)
|
|
49
|
-
else
|
|
50
|
-
aref_before_sequel(v)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
33
|
+
class Symbol
|
|
34
|
+
prepend Sequel::SymbolAref
|
|
54
35
|
end
|
|
55
|
-
# :nocov:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen-string-literal: true
|
|
2
2
|
#
|
|
3
3
|
# The symbol_aref_refinement extension adds a refinement that makes
|
|
4
|
-
# Symbol#[] support Symbol, #Sequel::SQL::
|
|
4
|
+
# Symbol#[] support Symbol, #Sequel::SQL::Identifier, and
|
|
5
5
|
# Sequel::SQL::QualifiedIdentifier instances, returning appropriate
|
|
6
6
|
# Sequel::SQL::QualifiedIdentifier instances. It's designed as a
|
|
7
7
|
# shortcut so that instead of:
|
|
@@ -25,10 +25,7 @@
|
|
|
25
25
|
#
|
|
26
26
|
# Related module: Sequel::SymbolAref
|
|
27
27
|
|
|
28
|
-
#
|
|
29
|
-
raise(Sequel::Error, "Refinements require ruby 2.0.0 or greater") unless RUBY_VERSION >= '2.0.0'
|
|
30
|
-
# :nocov:
|
|
31
|
-
|
|
28
|
+
#
|
|
32
29
|
module Sequel::SymbolAref
|
|
33
30
|
refine Symbol do
|
|
34
31
|
def [](v)
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
#
|
|
15
15
|
# Sequel.extension :symbol_as
|
|
16
16
|
#
|
|
17
|
-
#
|
|
18
|
-
# is a refinement version of this in the symbol_as_refinement extension.
|
|
17
|
+
# There is a refinement version of this in the symbol_as_refinement extension.
|
|
19
18
|
|
|
20
19
|
#
|
|
21
20
|
class Symbol
|
|
@@ -23,10 +23,7 @@
|
|
|
23
23
|
#
|
|
24
24
|
# Related module: Sequel::SymbolAs
|
|
25
25
|
|
|
26
|
-
#
|
|
27
|
-
raise(Sequel::Error, "Refinements require ruby 2.0.0 or greater") unless RUBY_VERSION >= '2.0.0'
|
|
28
|
-
# :nocov:
|
|
29
|
-
|
|
26
|
+
#
|
|
30
27
|
module Sequel::SymbolAs
|
|
31
28
|
refine Symbol do
|
|
32
29
|
def as(aliaz, columns=nil)
|
|
@@ -34,4 +31,3 @@ module Sequel::SymbolAs
|
|
|
34
31
|
end
|
|
35
32
|
end
|
|
36
33
|
end
|
|
37
|
-
|
|
@@ -33,7 +33,7 @@ module Sequel
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Rescue disconnect errors raised when beginning a new transaction. If there
|
|
36
|
-
# is a
|
|
36
|
+
# is a disconnect error, it should be safe to retry the transaction using a
|
|
37
37
|
# new connection, as we haven't yielded control to the user yet.
|
|
38
38
|
def transaction(opts=OPTS)
|
|
39
39
|
super
|