sequel 5.60.0 → 5.60.1
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/CHANGELOG +4 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +1 -1
- data/lib/sequel/adapters/jdbc.rb +5 -5
- data/lib/sequel/adapters/mock.rb +1 -1
- data/lib/sequel/adapters/mysql.rb +3 -3
- data/lib/sequel/adapters/oracle.rb +1 -1
- data/lib/sequel/adapters/postgres.rb +6 -6
- data/lib/sequel/adapters/shared/mssql.rb +1 -1
- data/lib/sequel/adapters/shared/oracle.rb +1 -1
- data/lib/sequel/adapters/sqlite.rb +1 -1
- data/lib/sequel/ast_transformer.rb +1 -1
- data/lib/sequel/database/misc.rb +2 -2
- data/lib/sequel/dataset/sql.rb +2 -2
- data/lib/sequel/extensions/duplicate_columns_handler.rb +1 -1
- data/lib/sequel/extensions/pg_array.rb +2 -2
- data/lib/sequel/extensions/pg_array_ops.rb +1 -1
- data/lib/sequel/extensions/pg_enum.rb +1 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +3 -3
- data/lib/sequel/extensions/pg_inet.rb +2 -2
- data/lib/sequel/extensions/pg_interval.rb +1 -1
- data/lib/sequel/extensions/pg_json.rb +1 -1
- data/lib/sequel/extensions/pg_json_ops.rb +3 -3
- data/lib/sequel/extensions/pg_multirange.rb +2 -2
- data/lib/sequel/extensions/pg_range.rb +2 -2
- data/lib/sequel/extensions/pg_row.rb +2 -2
- data/lib/sequel/extensions/pg_static_cache_updater.rb +2 -2
- data/lib/sequel/model/associations.rb +6 -6
- data/lib/sequel/model/base.rb +3 -3
- data/lib/sequel/model/exceptions.rb +1 -1
- data/lib/sequel/model/inflections.rb +6 -6
- data/lib/sequel/plugins/auto_validations.rb +1 -1
- data/lib/sequel/plugins/defaults_setter.rb +1 -1
- data/lib/sequel/plugins/dirty.rb +1 -1
- data/lib/sequel/plugins/insert_conflict.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +1 -1
- data/lib/sequel/plugins/nested_attributes.rb +1 -1
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +1 -1
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/sharding.rb +1 -1
- data/lib/sequel/plugins/subclasses.rb +1 -1
- data/lib/sequel/plugins/validation_class_methods.rb +3 -3
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/sql.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd8695696d6b55edf6337870f3ff172aeb6fe2ef9ba4bbc23daae0af26908649
|
4
|
+
data.tar.gz: 2483bbb3549adbcb9f179165119051b7bb234d6e714e4afa116c0ffddf379dc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0527cba1fcc06d8001cbd55473b3af5c23a9f5c004113fc24aa6f9e029c5ed2cf4f938bf184d79922164cdc3ea502d12860d46d64237bdbd306bf5ce50f59ffa
|
7
|
+
data.tar.gz: e13c17553592773e70c0e9a6753438444a5245f3cd0664c6c5a6c0a08a271d1d92180b110c7b7e5981f7ca6dc2b18d90da3feeb05a14ae863fcfd99d5673650e
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
=== 5.60.1 (2022-09-02)
|
2
|
+
|
3
|
+
* Revert conversion of respond_to? to defined?, as it breaks with unused refinements on Ruby 2 (jeremyevans) (#1919)
|
4
|
+
|
1
5
|
=== 5.60.0 (2022-09-01)
|
2
6
|
|
3
7
|
* Support arbitrary expressions for date_arithmetic interval values on PostgreSQL 9.4+ (jeremyevans)
|
@@ -125,7 +125,7 @@ module Sequel
|
|
125
125
|
|
126
126
|
# The result code for the exception, if the jdbc driver supports result codes for exceptions.
|
127
127
|
def sqlite_error_code(exception)
|
128
|
-
exception.resultCode.code if
|
128
|
+
exception.resultCode.code if exception.respond_to?(:resultCode)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -38,7 +38,7 @@ module Sequel
|
|
38
38
|
else
|
39
39
|
if defined?(::Jdbc) && ( ::Jdbc.const_defined?(name) rescue nil )
|
40
40
|
jdbc_module = ::Jdbc.const_get(name) # e.g. Jdbc::SQLite3
|
41
|
-
jdbc_module.load_driver if
|
41
|
+
jdbc_module.load_driver if jdbc_module.respond_to?(:load_driver)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -396,9 +396,9 @@ module Sequel
|
|
396
396
|
|
397
397
|
def database_exception_sqlstate(exception, opts)
|
398
398
|
if database_exception_use_sqlstates?
|
399
|
-
while
|
399
|
+
while exception.respond_to?(:cause)
|
400
400
|
exception = exception.cause
|
401
|
-
return exception.getSQLState if
|
401
|
+
return exception.getSQLState if exception.respond_to?(:getSQLState)
|
402
402
|
end
|
403
403
|
end
|
404
404
|
nil
|
@@ -415,8 +415,8 @@ module Sequel
|
|
415
415
|
|
416
416
|
# Raise a disconnect error if the SQL state of the cause of the exception indicates so.
|
417
417
|
def disconnect_error?(exception, opts)
|
418
|
-
cause =
|
419
|
-
super || (
|
418
|
+
cause = exception.respond_to?(:cause) ? exception.cause : exception
|
419
|
+
super || (cause.respond_to?(:getSQLState) && cause.getSQLState =~ /^08/)
|
420
420
|
end
|
421
421
|
|
422
422
|
# Execute the prepared statement. If the provided name is a
|
data/lib/sequel/adapters/mock.rb
CHANGED
@@ -72,7 +72,7 @@ module Sequel
|
|
72
72
|
def connect(server)
|
73
73
|
opts = server_opts(server)
|
74
74
|
|
75
|
-
if
|
75
|
+
if Mysql.respond_to?(:init)
|
76
76
|
conn = Mysql.init
|
77
77
|
conn.options(Mysql::READ_DEFAULT_GROUP, opts[:config_default_group] || "client")
|
78
78
|
conn.options(Mysql::OPT_LOCAL_INFILE, opts[:config_local_infile]) if opts.has_key?(:config_local_infile)
|
@@ -186,7 +186,7 @@ module Sequel
|
|
186
186
|
elsif defined?(yield)
|
187
187
|
yield conn
|
188
188
|
end
|
189
|
-
if
|
189
|
+
if conn.respond_to?(:more_results?)
|
190
190
|
while conn.more_results? do
|
191
191
|
if r
|
192
192
|
r.free
|
@@ -207,7 +207,7 @@ module Sequel
|
|
207
207
|
ensure
|
208
208
|
r.free if r
|
209
209
|
# Use up all results to avoid a commands out of sync message.
|
210
|
-
if
|
210
|
+
if conn.respond_to?(:more_results?)
|
211
211
|
while conn.more_results? do
|
212
212
|
begin
|
213
213
|
conn.next_result
|
@@ -149,7 +149,7 @@ module Sequel
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def database_specific_error_class(exception, opts)
|
152
|
-
return super unless
|
152
|
+
return super unless exception.respond_to?(:code)
|
153
153
|
case exception.code
|
154
154
|
when 1400, 1407
|
155
155
|
NotNullConstraintViolation
|
@@ -160,7 +160,7 @@ module Sequel
|
|
160
160
|
begin
|
161
161
|
defined?(yield) ? yield(q) : q.cmd_tuples
|
162
162
|
ensure
|
163
|
-
q.clear if q &&
|
163
|
+
q.clear if q && q.respond_to?(:clear)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -258,7 +258,7 @@ module Sequel
|
|
258
258
|
|
259
259
|
# :nocov:
|
260
260
|
if encoding = opts[:encoding] || opts[:charset]
|
261
|
-
if
|
261
|
+
if conn.respond_to?(:set_client_encoding)
|
262
262
|
conn.set_client_encoding(encoding)
|
263
263
|
else
|
264
264
|
conn.async_exec("set client_encoding to '#{encoding}'")
|
@@ -492,12 +492,12 @@ module Sequel
|
|
492
492
|
opts[:after_listen].call(conn) if opts[:after_listen]
|
493
493
|
timeout = opts[:timeout]
|
494
494
|
if timeout
|
495
|
-
timeout_block =
|
495
|
+
timeout_block = timeout.respond_to?(:call) ? timeout : proc{timeout}
|
496
496
|
end
|
497
497
|
|
498
498
|
if l = opts[:loop]
|
499
499
|
raise Error, 'calling #listen with :loop requires a block' unless block
|
500
|
-
loop_call =
|
500
|
+
loop_call = l.respond_to?(:call)
|
501
501
|
catch(:stop) do
|
502
502
|
while true
|
503
503
|
t = timeout_block ? [timeout_block.call] : []
|
@@ -582,7 +582,7 @@ module Sequel
|
|
582
582
|
|
583
583
|
def database_exception_sqlstate(exception, opts)
|
584
584
|
# :nocov:
|
585
|
-
if
|
585
|
+
if exception.respond_to?(:result) && (result = exception.result)
|
586
586
|
# :nocov:
|
587
587
|
result.error_field(PGresult::PG_DIAG_SQLSTATE)
|
588
588
|
end
|
@@ -625,7 +625,7 @@ module Sequel
|
|
625
625
|
begin
|
626
626
|
defined?(yield) ? yield(q) : q.cmd_tuples
|
627
627
|
ensure
|
628
|
-
q.clear if q &&
|
628
|
+
q.clear if q && q.respond_to?(:clear)
|
629
629
|
end
|
630
630
|
end
|
631
631
|
|
@@ -205,7 +205,7 @@ module Sequel
|
|
205
205
|
return @server_version = Integer(@opts[:server_version])
|
206
206
|
end
|
207
207
|
@server_version = synchronize(server) do |conn|
|
208
|
-
(conn.server_version rescue nil) if
|
208
|
+
(conn.server_version rescue nil) if conn.respond_to?(:server_version)
|
209
209
|
end
|
210
210
|
unless @server_version
|
211
211
|
m = /^(\d+)\.(\d+)\.(\d+)/.match(fetch("SELECT CAST(SERVERPROPERTY('ProductVersion') AS varchar)").single_value.to_s)
|
@@ -121,7 +121,7 @@ module Sequel
|
|
121
121
|
def server_version(server=nil)
|
122
122
|
return @server_version if @server_version
|
123
123
|
@server_version = synchronize(server) do |conn|
|
124
|
-
(conn.server_version rescue nil) if
|
124
|
+
(conn.server_version rescue nil) if conn.respond_to?(:server_version)
|
125
125
|
end
|
126
126
|
unless @server_version
|
127
127
|
@server_version = if m = /(\d+)\.(\d+)\.?(\d+)?\.?(\d+)?/.match(fetch("select version from PRODUCT_COMPONENT_VERSION where lower(product) like 'oracle%'").single_value)
|
@@ -305,7 +305,7 @@ module Sequel
|
|
305
305
|
if USE_EXTENDED_RESULT_CODES
|
306
306
|
# Support SQLite exception codes if ruby-sqlite3 supports them.
|
307
307
|
def sqlite_error_code(exception)
|
308
|
-
exception.code if
|
308
|
+
exception.code if exception.respond_to?(:code)
|
309
309
|
end
|
310
310
|
end
|
311
311
|
end
|
data/lib/sequel/database/misc.rb
CHANGED
@@ -350,7 +350,7 @@ module Sequel
|
|
350
350
|
# strings with all whitespace, and ones that respond
|
351
351
|
# true to empty?
|
352
352
|
def blank_object?(obj)
|
353
|
-
return obj.blank? if
|
353
|
+
return obj.blank? if obj.respond_to?(:blank?)
|
354
354
|
case obj
|
355
355
|
when NilClass, FalseClass
|
356
356
|
true
|
@@ -359,7 +359,7 @@ module Sequel
|
|
359
359
|
when String
|
360
360
|
obj.strip.empty?
|
361
361
|
else
|
362
|
-
|
362
|
+
obj.respond_to?(:empty?) ? obj.empty? : false
|
363
363
|
end
|
364
364
|
end
|
365
365
|
|
data/lib/sequel/dataset/sql.rb
CHANGED
@@ -1398,9 +1398,9 @@ module Sequel
|
|
1398
1398
|
# don't cache SQL for a dataset that uses this.
|
1399
1399
|
disable_sql_caching!
|
1400
1400
|
|
1401
|
-
if
|
1401
|
+
if v.respond_to?(:sql_literal_append)
|
1402
1402
|
v.sql_literal_append(self, sql)
|
1403
|
-
elsif
|
1403
|
+
elsif v.respond_to?(:sql_literal)
|
1404
1404
|
sql << v.sql_literal(self)
|
1405
1405
|
else
|
1406
1406
|
raise Error, "can't express #{v.inspect} as a SQL literal"
|
@@ -301,7 +301,7 @@ module Sequel
|
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
304
|
-
unless
|
304
|
+
unless Sequel::Postgres.respond_to?(:parse_pg_array)
|
305
305
|
require 'strscan'
|
306
306
|
|
307
307
|
# PostgreSQL array parser that handles PostgreSQL array output format.
|
@@ -412,7 +412,7 @@ module Sequel
|
|
412
412
|
@converter = converter
|
413
413
|
end
|
414
414
|
|
415
|
-
if
|
415
|
+
if Sequel::Postgres.respond_to?(:parse_pg_array)
|
416
416
|
# :nocov:
|
417
417
|
# Use sequel_pg's C-based parser if it has already been defined.
|
418
418
|
def call(string)
|
@@ -144,7 +144,7 @@ module Sequel
|
|
144
144
|
select_hash_groups(Sequel.cast(:enumtypid, Integer).as(:v), :enumlabel).freeze
|
145
145
|
enum_labels.each_value(&:freeze)
|
146
146
|
|
147
|
-
if
|
147
|
+
if respond_to?(:register_array_type)
|
148
148
|
array_types = metadata_dataset.
|
149
149
|
from(:pg_type).
|
150
150
|
where(:oid=>enum_labels.keys).
|
@@ -296,7 +296,7 @@ module Sequel
|
|
296
296
|
|
297
297
|
# Wrap argument in a PGArray if it is an array
|
298
298
|
def wrap_input_array(obj)
|
299
|
-
if obj.is_a?(Array) &&
|
299
|
+
if obj.is_a?(Array) && Sequel.respond_to?(:pg_array)
|
300
300
|
Sequel.pg_array(obj)
|
301
301
|
else
|
302
302
|
obj
|
@@ -305,7 +305,7 @@ module Sequel
|
|
305
305
|
|
306
306
|
# Wrap argument in an Hstore if it is a hash
|
307
307
|
def wrap_input_hash(obj)
|
308
|
-
if obj.is_a?(Hash) &&
|
308
|
+
if obj.is_a?(Hash) && Sequel.respond_to?(:hstore)
|
309
309
|
Sequel.hstore(obj)
|
310
310
|
else
|
311
311
|
obj
|
@@ -314,7 +314,7 @@ module Sequel
|
|
314
314
|
|
315
315
|
# Wrap argument in a PGArrayOp if supported
|
316
316
|
def wrap_output_array(obj)
|
317
|
-
if
|
317
|
+
if Sequel.respond_to?(:pg_array_op)
|
318
318
|
Sequel.pg_array_op(obj)
|
319
319
|
else
|
320
320
|
obj
|
@@ -49,13 +49,13 @@ module Sequel
|
|
49
49
|
meth = IPAddr.method(:new)
|
50
50
|
add_conversion_proc(869, meth)
|
51
51
|
add_conversion_proc(650, meth)
|
52
|
-
if
|
52
|
+
if respond_to?(:register_array_type)
|
53
53
|
register_array_type('inet', :oid=>1041, :scalar_oid=>869)
|
54
54
|
register_array_type('cidr', :oid=>651, :scalar_oid=>650)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
if
|
58
|
+
if respond_to?(:register_array_type)
|
59
59
|
register_array_type('macaddr', :oid=>1040, :scalar_oid=>829)
|
60
60
|
end
|
61
61
|
@schema_type_classes[:ipaddr] = IPAddr
|
@@ -144,7 +144,7 @@ module Sequel
|
|
144
144
|
db.instance_exec do
|
145
145
|
extend_datasets(IntervalDatasetMethods)
|
146
146
|
add_conversion_proc(1186, Postgres::IntervalDatabaseMethods::PARSER)
|
147
|
-
if
|
147
|
+
if respond_to?(:register_array_type)
|
148
148
|
register_array_type('interval', :oid=>1187, :scalar_oid=>1186)
|
149
149
|
end
|
150
150
|
@schema_type_classes[:interval] = ActiveSupport::Duration
|
@@ -227,7 +227,7 @@ module Sequel
|
|
227
227
|
db.instance_exec do
|
228
228
|
add_conversion_proc(114, method(:_db_parse_json))
|
229
229
|
add_conversion_proc(3802, method(:_db_parse_jsonb))
|
230
|
-
if
|
230
|
+
if respond_to?(:register_array_type)
|
231
231
|
register_array_type('json', :oid=>199, :scalar_oid=>114)
|
232
232
|
register_array_type('jsonb', :oid=>3807, :scalar_oid=>3802)
|
233
233
|
end
|
@@ -358,7 +358,7 @@ module Sequel
|
|
358
358
|
# Automatically wrap argument in a PGArray if it is a plain Array.
|
359
359
|
# Requires that the pg_array extension has been loaded to work.
|
360
360
|
def wrap_array(arg)
|
361
|
-
if arg.instance_of?(Array) &&
|
361
|
+
if arg.instance_of?(Array) && Sequel.respond_to?(:pg_array)
|
362
362
|
Sequel.pg_array(arg)
|
363
363
|
else
|
364
364
|
arg
|
@@ -652,7 +652,7 @@ module Sequel
|
|
652
652
|
|
653
653
|
# Wrap argument in a PGArray if it is an array
|
654
654
|
def wrap_input_array(obj)
|
655
|
-
if obj.is_a?(Array) &&
|
655
|
+
if obj.is_a?(Array) && Sequel.respond_to?(:pg_array)
|
656
656
|
Sequel.pg_array(obj)
|
657
657
|
else
|
658
658
|
obj
|
@@ -661,7 +661,7 @@ module Sequel
|
|
661
661
|
|
662
662
|
# Wrap argument in a JSONBArray or JSONBHash if it is an array or hash.
|
663
663
|
def wrap_input_jsonb(obj)
|
664
|
-
if
|
664
|
+
if Sequel.respond_to?(:pg_jsonb) && (obj.is_a?(Array) || obj.is_a?(Hash))
|
665
665
|
Sequel.pg_jsonb(obj)
|
666
666
|
else
|
667
667
|
obj
|
@@ -124,7 +124,7 @@ module Sequel
|
|
124
124
|
register_multirange_type('datemultirange', :range_oid=>3912, :oid=>4535)
|
125
125
|
register_multirange_type('int8multirange', :range_oid=>3926, :oid=>4536)
|
126
126
|
|
127
|
-
if
|
127
|
+
if respond_to?(:register_array_type)
|
128
128
|
register_array_type('int4multirange', :oid=>6150, :scalar_oid=>4451, :scalar_typecast=>:int4multirange)
|
129
129
|
register_array_type('nummultirange', :oid=>6151, :scalar_oid=>4532, :scalar_typecast=>:nummultirange)
|
130
130
|
register_array_type('tsmultirange', :oid=>6152, :scalar_oid=>4533, :scalar_typecast=>:tsmultirange)
|
@@ -141,7 +141,7 @@ module Sequel
|
|
141
141
|
add_conversion_proc(4533, PGMultiRange::Creator.new("tsmultirange", procs[3908]))
|
142
142
|
add_conversion_proc(4534, PGMultiRange::Creator.new("tstzmultirange", procs[3910]))
|
143
143
|
|
144
|
-
if
|
144
|
+
if respond_to?(:register_array_type) && defined?(PGArray::Creator)
|
145
145
|
add_conversion_proc(6152, PGArray::Creator.new("tsmultirange", procs[4533]))
|
146
146
|
add_conversion_proc(6153, PGArray::Creator.new("tstzmultirange", procs[4534]))
|
147
147
|
end
|
@@ -139,7 +139,7 @@ module Sequel
|
|
139
139
|
register_range_type('tstzrange', :oid=>3910, :subtype_oid=>1184)
|
140
140
|
register_range_type('daterange', :oid=>3912, :subtype_oid=>1082)
|
141
141
|
register_range_type('int8range', :oid=>3926, :subtype_oid=>20)
|
142
|
-
if
|
142
|
+
if respond_to?(:register_array_type)
|
143
143
|
register_array_type('int4range', :oid=>3905, :scalar_oid=>3904, :scalar_typecast=>:int4range)
|
144
144
|
register_array_type('numrange', :oid=>3907, :scalar_oid=>3906, :scalar_typecast=>:numrange)
|
145
145
|
register_array_type('tsrange', :oid=>3909, :scalar_oid=>3908, :scalar_typecast=>:tsrange)
|
@@ -154,7 +154,7 @@ module Sequel
|
|
154
154
|
procs = conversion_procs
|
155
155
|
add_conversion_proc(3908, Parser.new("tsrange", procs[1114]))
|
156
156
|
add_conversion_proc(3910, Parser.new("tstzrange", procs[1184]))
|
157
|
-
if
|
157
|
+
if respond_to?(:register_array_type) && defined?(PGArray::Creator)
|
158
158
|
add_conversion_proc(3909, PGArray::Creator.new("tsrange", procs[3908]))
|
159
159
|
add_conversion_proc(3911, PGArray::Creator.new("tstzrange", procs[3910]))
|
160
160
|
end
|
@@ -375,7 +375,7 @@ module Sequel
|
|
375
375
|
@row_schema_types = {}
|
376
376
|
extend(@row_type_method_module = Module.new)
|
377
377
|
add_conversion_proc(2249, PGRow::Parser.new(:converter=>PGRow::ArrayRow))
|
378
|
-
if
|
378
|
+
if respond_to?(:register_array_type)
|
379
379
|
register_array_type('record', :oid=>2287, :scalar_oid=>2249)
|
380
380
|
end
|
381
381
|
end
|
@@ -464,7 +464,7 @@ module Sequel
|
|
464
464
|
parser = Parser.new(parser_opts)
|
465
465
|
add_conversion_proc(parser.oid, parser)
|
466
466
|
|
467
|
-
if
|
467
|
+
if respond_to?(:register_array_type) && array_oid && array_oid > 0
|
468
468
|
array_type_name = if type_schema
|
469
469
|
"#{type_schema}.#{type_name}"
|
470
470
|
else
|
@@ -115,13 +115,13 @@ SQL
|
|
115
115
|
# :before_thread_exit :: An object that responds to +call+ that is called before the
|
116
116
|
# the created thread exits.
|
117
117
|
def listen_for_static_cache_updates(models, opts=OPTS)
|
118
|
-
raise Error, "this database object does not respond to listen, use the postgres adapter with the pg driver" unless
|
118
|
+
raise Error, "this database object does not respond to listen, use the postgres adapter with the pg driver" unless respond_to?(:listen)
|
119
119
|
models = [models] unless models.is_a?(Array)
|
120
120
|
raise Error, "array of models to listen for changes cannot be empty" if models.empty?
|
121
121
|
|
122
122
|
oid_map = {}
|
123
123
|
models.each do |model|
|
124
|
-
raise Error, "#{model.inspect} does not use the static_cache plugin" unless
|
124
|
+
raise Error, "#{model.inspect} does not use the static_cache plugin" unless model.respond_to?(:load_cache)
|
125
125
|
oid_map[get(regclass_oid(model.dataset.first_source_table))] = model
|
126
126
|
end
|
127
127
|
|
@@ -3016,7 +3016,7 @@ module Sequel
|
|
3016
3016
|
def complex_expression_sql_append(sql, op, args)
|
3017
3017
|
r = args[1]
|
3018
3018
|
if (((op == :'=' || op == :'!=') && r.is_a?(Sequel::Model)) ||
|
3019
|
-
(multiple = ((op == :IN || op == :'NOT IN') && ((is_ds = r.is_a?(Sequel::Dataset)) || (
|
3019
|
+
(multiple = ((op == :IN || op == :'NOT IN') && ((is_ds = r.is_a?(Sequel::Dataset)) || (r.respond_to?(:all?) && r.all?{|x| x.is_a?(Sequel::Model)})))))
|
3020
3020
|
l = args[0]
|
3021
3021
|
if ar = model.association_reflections[l]
|
3022
3022
|
raise Error, "filtering by associations is not allowed for #{ar.inspect}" if ar[:allow_filtering_by] == false
|
@@ -3024,7 +3024,7 @@ module Sequel
|
|
3024
3024
|
if multiple
|
3025
3025
|
klass = ar.associated_class
|
3026
3026
|
if is_ds
|
3027
|
-
if
|
3027
|
+
if r.respond_to?(:model)
|
3028
3028
|
unless r.model <= klass
|
3029
3029
|
# A dataset for a different model class, could be a valid regular query
|
3030
3030
|
return super
|
@@ -3356,10 +3356,10 @@ module Sequel
|
|
3356
3356
|
assoc_table_alias = ds.unused_table_alias(alias_base)
|
3357
3357
|
loader = r[:eager_grapher]
|
3358
3358
|
if !associations.empty?
|
3359
|
-
if
|
3359
|
+
if associations.first.respond_to?(:call)
|
3360
3360
|
callback = associations.first
|
3361
3361
|
associations = {}
|
3362
|
-
elsif associations.length == 1 && (assocs = associations.first).is_a?(Hash) && assocs.length == 1 && (pr_assoc = assocs.to_a.first) &&
|
3362
|
+
elsif associations.length == 1 && (assocs = associations.first).is_a?(Hash) && assocs.length == 1 && (pr_assoc = assocs.to_a.first) && pr_assoc.first.respond_to?(:call)
|
3363
3363
|
callback, assoc = pr_assoc
|
3364
3364
|
associations = assoc.is_a?(Array) ? assoc : [assoc]
|
3365
3365
|
end
|
@@ -3601,10 +3601,10 @@ module Sequel
|
|
3601
3601
|
end
|
3602
3602
|
|
3603
3603
|
associations = eager_assoc[r[:name]]
|
3604
|
-
if
|
3604
|
+
if associations.respond_to?(:call)
|
3605
3605
|
eager_block = associations
|
3606
3606
|
associations = OPTS
|
3607
|
-
elsif associations.is_a?(Hash) && associations.length == 1 && (pr_assoc = associations.to_a.first) &&
|
3607
|
+
elsif associations.is_a?(Hash) && associations.length == 1 && (pr_assoc = associations.to_a.first) && pr_assoc.first.respond_to?(:call)
|
3608
3608
|
eager_block, associations = pr_assoc
|
3609
3609
|
end
|
3610
3610
|
|
data/lib/sequel/model/base.rb
CHANGED
@@ -492,13 +492,13 @@ module Sequel
|
|
492
492
|
def plugin(plugin, *args, &block)
|
493
493
|
m = plugin.is_a?(Module) ? plugin : plugin_module(plugin)
|
494
494
|
|
495
|
-
if !
|
495
|
+
if !m.respond_to?(:apply) && !m.respond_to?(:configure) && (!args.empty? || block)
|
496
496
|
Deprecation.deprecate("Plugin #{plugin} accepts no arguments or block, and passing arguments/block to it", "Remove arguments and block when loading the plugin")
|
497
497
|
end
|
498
498
|
|
499
499
|
unless @plugins.include?(m)
|
500
500
|
@plugins << m
|
501
|
-
m.apply(self, *args, &block) if
|
501
|
+
m.apply(self, *args, &block) if m.respond_to?(:apply)
|
502
502
|
extend(m::ClassMethods) if m.const_defined?(:ClassMethods, false)
|
503
503
|
include(m::InstanceMethods) if m.const_defined?(:InstanceMethods, false)
|
504
504
|
if m.const_defined?(:DatasetMethods, false)
|
@@ -506,7 +506,7 @@ module Sequel
|
|
506
506
|
end
|
507
507
|
end
|
508
508
|
|
509
|
-
m.configure(self, *args, &block) if
|
509
|
+
m.configure(self, *args, &block) if m.respond_to?(:configure)
|
510
510
|
end
|
511
511
|
# :nocov:
|
512
512
|
ruby2_keywords(:plugin) if respond_to?(:ruby2_keywords, true)
|
@@ -99,7 +99,7 @@ module Sequel
|
|
99
99
|
# Convert the given string to CamelCase. Will also convert '/' to '::' which is useful for converting paths to namespaces.
|
100
100
|
def camelize(s)
|
101
101
|
s = s.to_s
|
102
|
-
return s.camelize if
|
102
|
+
return s.camelize if s.respond_to?(:camelize)
|
103
103
|
s = s.gsub(/\/(.?)/){|x| "::#{x[-1..-1].upcase unless x == '/'}"}.gsub(/(^|_)(.)/){|x| x[-1..-1].upcase}
|
104
104
|
s
|
105
105
|
end
|
@@ -109,7 +109,7 @@ module Sequel
|
|
109
109
|
# or is not initialized.
|
110
110
|
def constantize(s)
|
111
111
|
s = s.to_s
|
112
|
-
return s.constantize if
|
112
|
+
return s.constantize if s.respond_to?(:constantize)
|
113
113
|
raise(NameError, "#{s.inspect} is not a valid constant name!") unless m = /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/.match(s)
|
114
114
|
Object.module_eval("::#{m[1]}", __FILE__, __LINE__)
|
115
115
|
end
|
@@ -117,14 +117,14 @@ module Sequel
|
|
117
117
|
# Removes the module part from the expression in the string
|
118
118
|
def demodulize(s)
|
119
119
|
s = s.to_s
|
120
|
-
return s.demodulize if
|
120
|
+
return s.demodulize if s.respond_to?(:demodulize)
|
121
121
|
s.gsub(/^.*::/, '')
|
122
122
|
end
|
123
123
|
|
124
124
|
# Returns the plural form of the word in the string.
|
125
125
|
def pluralize(s)
|
126
126
|
s = s.to_s
|
127
|
-
return s.pluralize if
|
127
|
+
return s.pluralize if s.respond_to?(:pluralize)
|
128
128
|
result = s.dup
|
129
129
|
Inflections.plurals.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
|
130
130
|
result
|
@@ -133,7 +133,7 @@ module Sequel
|
|
133
133
|
# The reverse of pluralize, returns the singular form of a word in a string.
|
134
134
|
def singularize(s)
|
135
135
|
s = s.to_s
|
136
|
-
return s.singularize if
|
136
|
+
return s.singularize if s.respond_to?(:singularize)
|
137
137
|
result = s.dup
|
138
138
|
Inflections.singulars.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
|
139
139
|
result
|
@@ -143,7 +143,7 @@ module Sequel
|
|
143
143
|
# Also changes '::' to '/' to convert namespaces to paths.
|
144
144
|
def underscore(s)
|
145
145
|
s = s.to_s
|
146
|
-
return s.underscore if
|
146
|
+
return s.underscore if s.respond_to?(:underscore)
|
147
147
|
s.gsub('::', '/').gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
148
148
|
gsub(/([a-z\d])([A-Z])/, '\1_\2').tr('-', '_').downcase
|
149
149
|
end
|
@@ -252,7 +252,7 @@ module Sequel
|
|
252
252
|
|
253
253
|
unless skip.include?(:unique)
|
254
254
|
unique_opts = Hash[opts[:unique]]
|
255
|
-
if
|
255
|
+
if model.respond_to?(:sti_dataset)
|
256
256
|
unique_opts[:dataset] = model.sti_dataset
|
257
257
|
end
|
258
258
|
model.auto_validate_unique_columns.each{|cols| validates_unique(cols, unique_opts)}
|
data/lib/sequel/plugins/dirty.rb
CHANGED
@@ -203,7 +203,7 @@ module Sequel
|
|
203
203
|
get_column_value(column)
|
204
204
|
end
|
205
205
|
|
206
|
-
initial_values[column] = if value && value != true &&
|
206
|
+
initial_values[column] = if value && value != true && value.respond_to?(:clone)
|
207
207
|
begin
|
208
208
|
value.clone
|
209
209
|
rescue TypeError
|
@@ -36,7 +36,7 @@ module Sequel
|
|
36
36
|
module InsertConflict
|
37
37
|
def self.configure(model)
|
38
38
|
model.instance_exec do
|
39
|
-
if @dataset &&
|
39
|
+
if @dataset && !@dataset.respond_to?(:insert_conflict)
|
40
40
|
raise Error, "#{self}'s dataset does not support insert_conflict"
|
41
41
|
end
|
42
42
|
end
|
@@ -259,7 +259,7 @@ module Sequel
|
|
259
259
|
# specific :fields if configured.
|
260
260
|
def nested_attributes_set_attributes(meta, obj, attributes)
|
261
261
|
if fields = meta[:fields]
|
262
|
-
fields = fields.call(obj) if
|
262
|
+
fields = fields.call(obj) if fields.respond_to?(:call)
|
263
263
|
obj.set_fields(attributes, fields, :missing=>:skip)
|
264
264
|
else
|
265
265
|
obj.set(attributes)
|
@@ -159,7 +159,7 @@ module Sequel
|
|
159
159
|
|
160
160
|
case @dataset.first_source_table
|
161
161
|
when Symbol, String, SQL::Identifier, SQL::QualifiedIdentifier
|
162
|
-
convert_errors =
|
162
|
+
convert_errors = db.respond_to?(:error_info)
|
163
163
|
end
|
164
164
|
|
165
165
|
unless convert_errors
|
@@ -162,7 +162,7 @@ module Sequel
|
|
162
162
|
if !cc.include?(column) && (new? || get_column_value(column) != v)
|
163
163
|
cc << column
|
164
164
|
|
165
|
-
will_change_column(column) if
|
165
|
+
will_change_column(column) if respond_to?(:will_change_column)
|
166
166
|
end
|
167
167
|
|
168
168
|
deserialized_values[column] = v
|
@@ -91,7 +91,7 @@ module Sequel
|
|
91
91
|
# +many_to_many+ association, make sure the associated object is created on the
|
92
92
|
# current object's shard, unless the passed object already has an assigned shard.
|
93
93
|
def ensure_associated_primary_key(opts, o, *args)
|
94
|
-
o.set_server?(@server) if
|
94
|
+
o.set_server?(@server) if o.respond_to?(:set_server?)
|
95
95
|
super
|
96
96
|
end
|
97
97
|
|
@@ -35,7 +35,7 @@ module Sequel
|
|
35
35
|
# class B < Sequel::Model; end
|
36
36
|
# a # => [A, B]
|
37
37
|
module Subclasses
|
38
|
-
NEED_SUBCLASSES = !
|
38
|
+
NEED_SUBCLASSES = !Object.respond_to?(:subclasses) || Object.method(:subclasses).source_location
|
39
39
|
private_constant :NEED_SUBCLASSES
|
40
40
|
|
41
41
|
# Initialize the subclasses instance variable for the model.
|
@@ -282,7 +282,7 @@ module Sequel
|
|
282
282
|
o.errors.add(a, opts[:message] || opts[:wrong_length]) unless v && v.size == i
|
283
283
|
end
|
284
284
|
if w = opts[:within]
|
285
|
-
o.errors.add(a, opts[:message] || opts[:wrong_length]) unless v && w.public_send(
|
285
|
+
o.errors.add(a, opts[:message] || opts[:wrong_length]) unless v && w.public_send(w.respond_to?(:cover?) ? :cover? : :include?, v.size)
|
286
286
|
end
|
287
287
|
end
|
288
288
|
end
|
@@ -337,14 +337,14 @@ module Sequel
|
|
337
337
|
def validates_inclusion_of(*atts)
|
338
338
|
opts = extract_options!(atts)
|
339
339
|
n = opts[:in]
|
340
|
-
unless n && (
|
340
|
+
unless n && (n.respond_to?(:cover?) || n.respond_to?(:include?))
|
341
341
|
raise ArgumentError, "The :in parameter is required, and must respond to cover? or include?"
|
342
342
|
end
|
343
343
|
opts[:message] ||= "is not in range or set: #{n.inspect}"
|
344
344
|
reflect_validation(:inclusion, opts, atts)
|
345
345
|
atts << opts
|
346
346
|
validates_each(*atts) do |o, a, v|
|
347
|
-
o.errors.add(a, opts[:message]) unless n.public_send(
|
347
|
+
o.errors.add(a, opts[:message]) unless n.public_send(n.respond_to?(:cover?) ? :cover? : :include?, v)
|
348
348
|
end
|
349
349
|
end
|
350
350
|
|
@@ -107,7 +107,7 @@ module Sequel
|
|
107
107
|
|
108
108
|
# Check attribute value(s) is included in the given set.
|
109
109
|
def validates_includes(set, atts, opts=OPTS)
|
110
|
-
validatable_attributes_for_type(:includes, atts, opts){|a,v,m| validation_error_message(m, set) unless set.public_send(
|
110
|
+
validatable_attributes_for_type(:includes, atts, opts){|a,v,m| validation_error_message(m, set) unless set.public_send(set.respond_to?(:cover?) ? :cover? : :include?, v)}
|
111
111
|
end
|
112
112
|
|
113
113
|
# Check attribute value(s) string representation is a valid integer.
|
data/lib/sequel/sql.rb
CHANGED
@@ -1347,7 +1347,7 @@ module Sequel
|
|
1347
1347
|
# underlying callable only accepts a single argument, call it
|
1348
1348
|
# with the given dataset.
|
1349
1349
|
def call(ds)
|
1350
|
-
if
|
1350
|
+
if @callable.respond_to?(:arity) && @callable.arity == 1
|
1351
1351
|
@callable.call(ds)
|
1352
1352
|
else
|
1353
1353
|
@callable.call
|
data/lib/sequel/version.rb
CHANGED
@@ -10,7 +10,7 @@ module Sequel
|
|
10
10
|
|
11
11
|
# The tiny version of Sequel. Usually 0, only bumped for bugfix
|
12
12
|
# releases that fix regressions from previous versions.
|
13
|
-
TINY =
|
13
|
+
TINY = 1
|
14
14
|
|
15
15
|
# The version of Sequel you are using, as a string (e.g. "2.11.0")
|
16
16
|
VERSION = [MAJOR, MINOR, TINY].join('.').freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.60.
|
4
|
+
version: 5.60.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|