sequel 5.51.0 → 5.54.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +44 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +5 -0
  5. data/doc/opening_databases.rdoc +1 -1
  6. data/doc/release_notes/5.52.0.txt +87 -0
  7. data/doc/release_notes/5.53.0.txt +23 -0
  8. data/doc/release_notes/5.54.0.txt +27 -0
  9. data/doc/testing.rdoc +3 -1
  10. data/lib/sequel/adapters/amalgalite.rb +3 -5
  11. data/lib/sequel/adapters/jdbc/h2.rb +55 -10
  12. data/lib/sequel/adapters/jdbc.rb +12 -14
  13. data/lib/sequel/adapters/mysql.rb +80 -67
  14. data/lib/sequel/adapters/mysql2.rb +53 -48
  15. data/lib/sequel/adapters/postgres.rb +17 -21
  16. data/lib/sequel/adapters/shared/mysql.rb +3 -2
  17. data/lib/sequel/adapters/shared/postgres.rb +2 -2
  18. data/lib/sequel/adapters/sqlite.rb +16 -18
  19. data/lib/sequel/adapters/utils/mysql_mysql2.rb +1 -1
  20. data/lib/sequel/connection_pool/sharded_single.rb +5 -7
  21. data/lib/sequel/connection_pool/single.rb +6 -8
  22. data/lib/sequel/core.rb +17 -18
  23. data/lib/sequel/database/query.rb +1 -1
  24. data/lib/sequel/extensions/core_refinements.rb +36 -11
  25. data/lib/sequel/extensions/date_parse_input_handler.rb +67 -0
  26. data/lib/sequel/extensions/datetime_parse_to_time.rb +5 -1
  27. data/lib/sequel/extensions/pg_array_ops.rb +2 -2
  28. data/lib/sequel/extensions/pg_hstore_ops.rb +1 -1
  29. data/lib/sequel/extensions/pg_inet_ops.rb +1 -1
  30. data/lib/sequel/extensions/pg_interval.rb +1 -0
  31. data/lib/sequel/extensions/pg_json.rb +3 -5
  32. data/lib/sequel/extensions/pg_json_ops.rb +1 -1
  33. data/lib/sequel/extensions/pg_range_ops.rb +1 -1
  34. data/lib/sequel/extensions/pg_row_ops.rb +1 -1
  35. data/lib/sequel/extensions/s.rb +2 -1
  36. data/lib/sequel/extensions/server_block.rb +8 -12
  37. data/lib/sequel/extensions/sql_comments.rb +110 -3
  38. data/lib/sequel/extensions/string_date_time.rb +19 -23
  39. data/lib/sequel/model/base.rb +8 -12
  40. data/lib/sequel/plugins/column_encryption.rb +1 -1
  41. data/lib/sequel/plugins/enum.rb +124 -0
  42. data/lib/sequel/plugins/sql_comments.rb +189 -0
  43. data/lib/sequel/plugins/subclasses.rb +28 -11
  44. data/lib/sequel/plugins/unused_associations.rb +2 -2
  45. data/lib/sequel/timezones.rb +12 -14
  46. data/lib/sequel/version.rb +1 -1
  47. metadata +12 -3
@@ -86,20 +86,26 @@ module Sequel
86
86
  if NativePreparedStatements
87
87
  # Use a native mysql2 prepared statement to implement prepared statements.
88
88
  def execute_prepared_statement(ps_name, opts, &block)
89
- ps = prepared_statement(ps_name)
89
+ if ps_name.is_a?(Sequel::Dataset::ArgumentMapper)
90
+ ps = ps_name
91
+ ps_name = ps.prepared_statement_name
92
+ else
93
+ ps = prepared_statement(ps_name)
94
+ end
90
95
  sql = ps.prepared_sql
91
96
 
92
97
  synchronize(opts[:server]) do |conn|
93
98
  stmt, ps_sql = conn.prepared_statements[ps_name]
94
99
  unless ps_sql == sql
95
100
  stmt.close if stmt
96
- stmt = log_connection_yield(conn, "Preparing #{ps_name}: #{sql}"){conn.prepare(sql)}
101
+ stmt = log_connection_yield("Preparing #{ps_name}: #{sql}", conn){conn.prepare(sql)}
97
102
  conn.prepared_statements[ps_name] = [stmt, sql]
98
103
  end
99
104
 
100
- if ps.log_sql
101
- opts = Hash[opts]
102
- opts = opts[:log_sql] = " (#{sql})"
105
+ opts = Hash[opts]
106
+ opts[:sql] = "Executing #{ps_name || sql}"
107
+ if ps_name && ps.log_sql
108
+ opts[:log_sql] = " (#{sql})"
103
109
  end
104
110
 
105
111
  _execute(conn, stmt, opts, &block)
@@ -111,56 +117,55 @@ module Sequel
111
117
  # option is :select, yield the result of the query, otherwise
112
118
  # yield the connection if a block is given.
113
119
  def _execute(conn, sql, opts)
114
- begin
115
- stream = opts[:stream]
116
- if NativePreparedStatements
117
- if args = opts[:arguments]
118
- args = args.map{|arg| bound_variable_value(arg)}
119
- end
120
+ stream = opts[:stream]
121
+ if NativePreparedStatements
122
+ if args = opts[:arguments]
123
+ args = args.map{|arg| bound_variable_value(arg)}
124
+ end
120
125
 
121
- case sql
122
- when ::Mysql2::Statement
123
- stmt = sql
124
- when Dataset
125
- sql = sql.sql
126
- close_stmt = true
127
- stmt = conn.prepare(sql)
128
- end
126
+ case sql
127
+ when ::Mysql2::Statement
128
+ stmt = sql
129
+ sql = opts[:sql] || ''
130
+ when Dataset
131
+ sql = sql.sql
132
+ close_stmt = true
133
+ stmt = conn.prepare(sql)
129
134
  end
135
+ end
130
136
 
131
- r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn, args) do
132
- if stmt
133
- conn.query_options.merge!(:cache_rows=>true, :database_timezone => timezone, :application_timezone => Sequel.application_timezone, :stream=>stream, :cast_booleans=>convert_tinyint_to_bool)
134
- stmt.execute(*args)
135
- else
136
- conn.query(sql, :database_timezone => timezone, :application_timezone => Sequel.application_timezone, :stream=>stream)
137
- end
137
+ r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn, args) do
138
+ if stmt
139
+ conn.query_options.merge!(:cache_rows=>true, :database_timezone => timezone, :application_timezone => Sequel.application_timezone, :stream=>stream, :cast_booleans=>convert_tinyint_to_bool)
140
+ stmt.execute(*args)
141
+ else
142
+ conn.query(sql, :database_timezone => timezone, :application_timezone => Sequel.application_timezone, :stream=>stream)
138
143
  end
139
- if opts[:type] == :select
140
- if r
141
- if stream
142
- begin
143
- r2 = yield r
144
- ensure
145
- # If r2 is nil, it means the block did not exit normally,
146
- # so the rest of the results must be drained to prevent
147
- # "commands out of sync" errors.
148
- r.each{} unless r2
149
- end
150
- else
151
- yield r
144
+ end
145
+ if opts[:type] == :select
146
+ if r
147
+ if stream
148
+ begin
149
+ r2 = yield r
150
+ ensure
151
+ # If r2 is nil, it means the block did not exit normally,
152
+ # so the rest of the results must be drained to prevent
153
+ # "commands out of sync" errors.
154
+ r.each{} unless r2
152
155
  end
156
+ else
157
+ yield r
153
158
  end
154
- elsif defined?(yield)
155
- yield conn
156
- end
157
- rescue ::Mysql2::Error => e
158
- raise_error(e)
159
- ensure
160
- if stmt
161
- conn.query_options.replace(conn.instance_variable_get(:@sequel_default_query_options))
162
- stmt.close if close_stmt
163
159
  end
160
+ elsif defined?(yield)
161
+ yield conn
162
+ end
163
+ rescue ::Mysql2::Error => e
164
+ raise_error(e)
165
+ ensure
166
+ if stmt
167
+ conn.query_options.replace(conn.instance_variable_get(:@sequel_default_query_options))
168
+ stmt.close if close_stmt
164
169
  end
165
170
  end
166
171
 
@@ -116,25 +116,23 @@ module Sequel
116
116
  # error classes is raised, or a PGError is raised and the connection
117
117
  # status cannot be determined or it is not OK.
118
118
  def check_disconnect_errors
119
+ yield
120
+ rescue *DISCONNECT_ERROR_CLASSES => e
121
+ disconnect = true
122
+ raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError))
123
+ rescue PGError => e
124
+ disconnect = false
119
125
  begin
120
- yield
121
- rescue *DISCONNECT_ERROR_CLASSES => e
126
+ s = status
127
+ rescue PGError
122
128
  disconnect = true
123
- raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError))
124
- rescue PGError => e
125
- disconnect = false
126
- begin
127
- s = status
128
- rescue PGError
129
- disconnect = true
130
- end
131
- status_ok = (s == Adapter::CONNECTION_OK)
132
- disconnect ||= !status_ok
133
- disconnect ||= e.message =~ DISCONNECT_ERROR_RE
134
- disconnect ? raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)) : raise
135
- ensure
136
- block if status_ok && !disconnect
137
129
  end
130
+ status_ok = (s == Adapter::CONNECTION_OK)
131
+ disconnect ||= !status_ok
132
+ disconnect ||= e.message =~ DISCONNECT_ERROR_RE
133
+ disconnect ? raise(Sequel.convert_exception_class(e, Sequel::DatabaseDisconnectError)) : raise
134
+ ensure
135
+ block if status_ok && !disconnect
138
136
  end
139
137
 
140
138
  # Execute the given SQL with this connection. If a block is given,
@@ -518,11 +516,9 @@ module Sequel
518
516
 
519
517
  # Convert exceptions raised from the block into DatabaseErrors.
520
518
  def check_database_errors
521
- begin
522
- yield
523
- rescue => e
524
- raise_error(e, :classes=>database_error_classes)
525
- end
519
+ yield
520
+ rescue => e
521
+ raise_error(e, :classes=>database_error_classes)
526
522
  end
527
523
 
528
524
  # Set the DateStyle to ISO if configured, for faster date parsing.
@@ -544,9 +544,10 @@ module Sequel
544
544
  server_version >= 50600 && (op[:op] == :drop_index || (op[:op] == :drop_constraint && op[:type] == :unique))
545
545
  end
546
546
 
547
- # Whether the database supports CHECK constraints
547
+ # CHECK constraints only supported on MariaDB 10.2+ and MySQL 8.0.19+
548
+ # (at least MySQL documents DROP CONSTRAINT was supported in 8.0.19+).
548
549
  def supports_check_constraints?
549
- mariadb? && server_version >= 100200
550
+ server_version >= (mariadb? ? 100200 : 80019)
550
551
  end
551
552
 
552
553
  # MySQL can combine multiple alter table ops into a single query.
@@ -1504,9 +1504,9 @@ module Sequel
1504
1504
  if column[:text]
1505
1505
  :text
1506
1506
  elsif column[:fixed]
1507
- "char(#{column[:size]||255})"
1507
+ "char(#{column[:size]||default_string_column_size})"
1508
1508
  elsif column[:text] == false || column[:size]
1509
- "varchar(#{column[:size]||255})"
1509
+ "varchar(#{column[:size]||default_string_column_size})"
1510
1510
  else
1511
1511
  :text
1512
1512
  end
@@ -189,26 +189,24 @@ module Sequel
189
189
  # Yield an available connection. Rescue
190
190
  # any SQLite3::Exceptions and turn them into DatabaseErrors.
191
191
  def _execute(type, sql, opts, &block)
192
- begin
193
- synchronize(opts[:server]) do |conn|
194
- return execute_prepared_statement(conn, type, sql, opts, &block) if sql.is_a?(Symbol)
195
- log_args = opts[:arguments]
196
- args = {}
197
- opts.fetch(:arguments, OPTS).each{|k, v| args[k] = prepared_statement_argument(v)}
198
- case type
199
- when :select
200
- log_connection_yield(sql, conn, log_args){conn.query(sql, args, &block)}
201
- when :insert
202
- log_connection_yield(sql, conn, log_args){conn.execute(sql, args)}
203
- conn.last_insert_row_id
204
- when :update
205
- log_connection_yield(sql, conn, log_args){conn.execute_batch(sql, args)}
206
- conn.changes
207
- end
192
+ synchronize(opts[:server]) do |conn|
193
+ return execute_prepared_statement(conn, type, sql, opts, &block) if sql.is_a?(Symbol)
194
+ log_args = opts[:arguments]
195
+ args = {}
196
+ opts.fetch(:arguments, OPTS).each{|k, v| args[k] = prepared_statement_argument(v)}
197
+ case type
198
+ when :select
199
+ log_connection_yield(sql, conn, log_args){conn.query(sql, args, &block)}
200
+ when :insert
201
+ log_connection_yield(sql, conn, log_args){conn.execute(sql, args)}
202
+ conn.last_insert_row_id
203
+ when :update
204
+ log_connection_yield(sql, conn, log_args){conn.execute_batch(sql, args)}
205
+ conn.changes
208
206
  end
209
- rescue SQLite3::Exception => e
210
- raise_error(e)
211
207
  end
208
+ rescue SQLite3::Exception => e
209
+ raise_error(e)
212
210
  end
213
211
 
214
212
  # The SQLite adapter does not need the pool to convert exceptions.
@@ -34,7 +34,7 @@ module Sequel
34
34
  def execute(sql, opts=OPTS, &block)
35
35
  if opts[:sproc]
36
36
  call_sproc(sql, opts, &block)
37
- elsif sql.is_a?(Symbol)
37
+ elsif sql.is_a?(Symbol) || sql.is_a?(Sequel::Dataset::ArgumentMapper)
38
38
  execute_prepared_statement(sql, opts, &block)
39
39
  else
40
40
  synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}
@@ -55,13 +55,11 @@ class Sequel::ShardedSingleConnectionPool < Sequel::ConnectionPool
55
55
  # Yields the connection to the supplied block for the given server.
56
56
  # This method simulates the ConnectionPool#hold API.
57
57
  def hold(server=:default)
58
- begin
59
- server = pick_server(server)
60
- yield(@conns[server] ||= make_new(server))
61
- rescue Sequel::DatabaseDisconnectError, *@error_classes => e
62
- disconnect_server(server) if disconnect_error?(e)
63
- raise
64
- end
58
+ server = pick_server(server)
59
+ yield(@conns[server] ||= make_new(server))
60
+ rescue Sequel::DatabaseDisconnectError, *@error_classes => e
61
+ disconnect_server(server) if disconnect_error?(e)
62
+ raise
65
63
  end
66
64
 
67
65
  # The ShardedSingleConnectionPool always has a maximum size of 1.
@@ -24,15 +24,13 @@ class Sequel::SingleConnectionPool < Sequel::ConnectionPool
24
24
 
25
25
  # Yield the connection to the block.
26
26
  def hold(server=nil)
27
- begin
28
- unless c = @conn.first
29
- @conn.replace([c = make_new(:default)])
30
- end
31
- yield c
32
- rescue Sequel::DatabaseDisconnectError, *@error_classes => e
33
- disconnect if disconnect_error?(e)
34
- raise
27
+ unless c = @conn.first
28
+ @conn.replace([c = make_new(:default)])
35
29
  end
30
+ yield c
31
+ rescue Sequel::DatabaseDisconnectError, *@error_classes => e
32
+ disconnect if disconnect_error?(e)
33
+ raise
36
34
  end
37
35
 
38
36
  # The SingleConnectionPool always has a maximum size of 1.
data/lib/sequel/core.rb CHANGED
@@ -278,11 +278,9 @@ module Sequel
278
278
  #
279
279
  # Sequel.string_to_date('2010-09-10') # Date.civil(2010, 09, 10)
280
280
  def string_to_date(string)
281
- begin
282
- Date.parse(string, Sequel.convert_two_digit_years)
283
- rescue => e
284
- raise convert_exception_class(e, InvalidValue)
285
- end
281
+ Date.parse(string, Sequel.convert_two_digit_years)
282
+ rescue => e
283
+ raise convert_exception_class(e, InvalidValue)
286
284
  end
287
285
 
288
286
  # Converts the given +string+ into a +Time+ or +DateTime+ object, depending on the
@@ -290,15 +288,13 @@ module Sequel
290
288
  #
291
289
  # Sequel.string_to_datetime('2010-09-10 10:20:30') # Time.local(2010, 09, 10, 10, 20, 30)
292
290
  def string_to_datetime(string)
293
- begin
294
- if datetime_class == DateTime
295
- DateTime.parse(string, convert_two_digit_years)
296
- else
297
- datetime_class.parse(string)
298
- end
299
- rescue => e
300
- raise convert_exception_class(e, InvalidValue)
291
+ if datetime_class == DateTime
292
+ DateTime.parse(string, convert_two_digit_years)
293
+ else
294
+ datetime_class.parse(string)
301
295
  end
296
+ rescue => e
297
+ raise convert_exception_class(e, InvalidValue)
302
298
  end
303
299
 
304
300
  # Converts the given +string+ into a <tt>Sequel::SQLTime</tt> object.
@@ -306,11 +302,9 @@ module Sequel
306
302
  # v = Sequel.string_to_time('10:20:30') # Sequel::SQLTime.parse('10:20:30')
307
303
  # DB.literal(v) # => '10:20:30'
308
304
  def string_to_time(string)
309
- begin
310
- SQLTime.parse(string)
311
- rescue => e
312
- raise convert_exception_class(e, InvalidValue)
313
- end
305
+ SQLTime.parse(string)
306
+ rescue => e
307
+ raise convert_exception_class(e, InvalidValue)
314
308
  end
315
309
 
316
310
  # Unless in single threaded mode, protects access to any mutable
@@ -400,6 +394,11 @@ module Sequel
400
394
 
401
395
  private
402
396
 
397
+ # Return a hash of date information parsed from the given string.
398
+ def _date_parse(string)
399
+ Date._parse(string)
400
+ end
401
+
403
402
  # Helper method that the database adapter class methods that are added to Sequel via
404
403
  # metaprogramming use to parse arguments.
405
404
  def adapter_method(adapter, *args, &block)
@@ -236,7 +236,7 @@ module Sequel
236
236
  when :date
237
237
  Sequel.string_to_date(default)
238
238
  when :datetime
239
- DateTime.parse(default)
239
+ Sequel.string_to_datetime(default)
240
240
  when :time
241
241
  Sequel.string_to_time(default)
242
242
  when :decimal
@@ -15,6 +15,12 @@ raise(Sequel::Error, "Refinements require ruby 2.0.0 or greater") unless RUBY_VE
15
15
  # :nocov:
16
16
 
17
17
  module Sequel::CoreRefinements
18
+ # :nocov:
19
+ include_meth = RUBY_VERSION >= '3.1' ? :import_methods : :include
20
+ # :nocov:
21
+ INCLUDE_METH = include_meth
22
+ private_constant :INCLUDE_METH
23
+
18
24
  refine Array do
19
25
  # Return a <tt>Sequel::SQL::BooleanExpression</tt> created from this array, not matching all of the
20
26
  # conditions.
@@ -161,8 +167,8 @@ module Sequel::CoreRefinements
161
167
  end
162
168
 
163
169
  refine String do
164
- include Sequel::SQL::AliasMethods
165
- include Sequel::SQL::CastMethods
170
+ send include_meth, Sequel::SQL::AliasMethods
171
+ send include_meth, Sequel::SQL::CastMethods
166
172
 
167
173
  # Converts a string into a <tt>Sequel::LiteralString</tt>, in order to override string
168
174
  # literalization, e.g.:
@@ -189,15 +195,34 @@ module Sequel::CoreRefinements
189
195
  end
190
196
 
191
197
  refine Symbol do
192
- include Sequel::SQL::AliasMethods
193
- include Sequel::SQL::CastMethods
194
- include Sequel::SQL::OrderMethods
195
- include Sequel::SQL::BooleanMethods
196
- include Sequel::SQL::NumericMethods
197
- include Sequel::SQL::QualifyingMethods
198
- include Sequel::SQL::StringMethods
199
- include Sequel::SQL::SubscriptMethods
200
- include Sequel::SQL::ComplexExpressionMethods
198
+ send include_meth, Sequel::SQL::AliasMethods
199
+ send include_meth, Sequel::SQL::CastMethods
200
+ send include_meth, Sequel::SQL::OrderMethods
201
+ send include_meth, Sequel::SQL::BooleanMethods
202
+ send include_meth, Sequel::SQL::NumericMethods
203
+
204
+ # :nocov:
205
+ remove_method :* if RUBY_VERSION >= '3.1'
206
+ # :nocov:
207
+
208
+ send include_meth, Sequel::SQL::QualifyingMethods
209
+ send include_meth, Sequel::SQL::StringMethods
210
+ send include_meth, Sequel::SQL::SubscriptMethods
211
+ send include_meth, Sequel::SQL::ComplexExpressionMethods
212
+
213
+ # :nocov:
214
+ if RUBY_VERSION >= '3.1'
215
+ remove_method :*
216
+ def *(ce=(arg=false;nil))
217
+ if arg == false
218
+ Sequel::SQL::ColumnAll.new(self)
219
+ else
220
+ Sequel::SQL::NumericExpression.new(:*, self, ce)
221
+ end
222
+ end
223
+
224
+ end
225
+ # :nocov:
201
226
 
202
227
  # Returns receiver wrapped in an <tt>Sequel::SQL::Identifier</tt>.
203
228
  #
@@ -0,0 +1,67 @@
1
+ # frozen-string-literal: true
2
+ #
3
+ # The date_parse_input_handler extension allows for configuring how input
4
+ # to date parsing methods should be handled. By default, the
5
+ # extension does not change behavior. However, you can use the
6
+ # +Sequel.date_parse_input_handler+ method to support custom handling
7
+ # of input strings to the date parsing methods. For example, if you want
8
+ # to implement a length check to prevent denial of service vulnerabilities
9
+ # in older versions of Ruby, you can do:
10
+ #
11
+ # Sequel.extension :date_parse_input_handler
12
+ # Sequel.date_parse_input_handler do |string|
13
+ # raise Sequel::InvalidValue, "string length (200) exceeds the limit 128" if string.bytesize > 128
14
+ # string
15
+ # end
16
+ #
17
+ # You can also use +Sequel.date_parse_input_handler+ to modify the string
18
+ # that will be passed to the parsing methods. For example, you could
19
+ # truncate it:
20
+ #
21
+ # Sequel.date_parse_input_handler do |string|
22
+ # string.b[0, 128]
23
+ # end
24
+ #
25
+ # Be aware that modern versions of Ruby will raise an exception if
26
+ # date parsing input exceeds 128 bytes.
27
+
28
+ module Sequel
29
+ module DateParseInputHandler
30
+ def date_parse_input_handler(&block)
31
+ singleton_class.class_eval do
32
+ define_method(:handle_date_parse_input, &block)
33
+ private :handle_date_parse_input
34
+ alias handle_date_parse_input handle_date_parse_input
35
+ end
36
+ end
37
+
38
+ # Call date parse input handler with input string.
39
+ def string_to_date(string)
40
+ super(handle_date_parse_input(string))
41
+ end
42
+
43
+ # Call date parse input handler with input string.
44
+ def string_to_datetime(string)
45
+ super(handle_date_parse_input(string))
46
+ end
47
+
48
+ # Call date parse input handler with input string.
49
+ def string_to_time(string)
50
+ super(handle_date_parse_input(string))
51
+ end
52
+
53
+ private
54
+
55
+ # Call date parse input handler with input string.
56
+ def _date_parse(string)
57
+ super(handle_date_parse_input(string))
58
+ end
59
+
60
+ # Return string as-is by default, so by default behavior does not change.
61
+ def handle_date_parse_input(string)
62
+ string
63
+ end
64
+ end
65
+
66
+ extend DateParseInputHandler
67
+ end
@@ -19,7 +19,11 @@ module Sequel::DateTimeParseToTime
19
19
  # Use DateTime.parse.to_time to do the conversion if the input a string and is assumed to
20
20
  # be in UTC and there is no offset information in the string.
21
21
  def convert_input_timestamp(v, input_timezone)
22
- if v.is_a?(String) && datetime_class == Time && input_timezone == :utc && !Date._parse(v).has_key?(:offset)
22
+ if v.is_a?(String) && datetime_class == Time && input_timezone == :utc && !_date_parse(v).has_key?(:offset)
23
+ # :nocov:
24
+ # Whether this is fully branch covered depends on the order in which the specs are run.
25
+ v = handle_date_parse_input(v) if respond_to?(:handle_date_parse_input, true)
26
+ # :nocov:
23
27
  t = DateTime.parse(v).to_time
24
28
  case application_timezone
25
29
  when nil, :local
@@ -108,7 +108,7 @@ module Sequel
108
108
 
109
109
  # Call the ANY function:
110
110
  #
111
- # array_op.all # ANY(array)
111
+ # array_op.any # ANY(array)
112
112
  #
113
113
  # Usually used like:
114
114
  #
@@ -329,7 +329,7 @@ end
329
329
  if defined?(Sequel::CoreRefinements)
330
330
  module Sequel::CoreRefinements
331
331
  refine Symbol do
332
- include Sequel::Postgres::ArrayOpMethods
332
+ send INCLUDE_METH, Sequel::Postgres::ArrayOpMethods
333
333
  end
334
334
  end
335
335
  end
@@ -406,7 +406,7 @@ end
406
406
  if defined?(Sequel::CoreRefinements)
407
407
  module Sequel::CoreRefinements
408
408
  refine Symbol do
409
- include Sequel::Postgres::HStoreOpMethods
409
+ send INCLUDE_METH, Sequel::Postgres::HStoreOpMethods
410
410
  end
411
411
  end
412
412
  end
@@ -197,7 +197,7 @@ end
197
197
  if defined?(Sequel::CoreRefinements)
198
198
  module Sequel::CoreRefinements
199
199
  refine Symbol do
200
- include Sequel::Postgres::InetOpMethods
200
+ send INCLUDE_METH, Sequel::Postgres::InetOpMethods
201
201
  end
202
202
  end
203
203
  end
@@ -32,6 +32,7 @@
32
32
  #
33
33
  # Related module: Sequel::Postgres::IntervalDatabaseMethods
34
34
 
35
+ require 'active_support'
35
36
  require 'active_support/duration'
36
37
 
37
38
  # :nocov:
@@ -387,11 +387,9 @@ module Sequel
387
387
  # argument is true), or a String, Numeric, true, false, or nil
388
388
  # if the json library used supports that.
389
389
  def _parse_json(s)
390
- begin
391
- Sequel.parse_json(s)
392
- rescue Sequel.json_parser_error_class => e
393
- raise Sequel.convert_exception_class(e, Sequel::InvalidValue)
394
- end
390
+ Sequel.parse_json(s)
391
+ rescue Sequel.json_parser_error_class => e
392
+ raise Sequel.convert_exception_class(e, Sequel::InvalidValue)
395
393
  end
396
394
 
397
395
  # Wrap the parsed JSON value in the appropriate JSON wrapper class.
@@ -744,7 +744,7 @@ end
744
744
  if defined?(Sequel::CoreRefinements)
745
745
  module Sequel::CoreRefinements
746
746
  refine Symbol do
747
- include Sequel::Postgres::JSONOpMethods
747
+ send INCLUDE_METH, Sequel::Postgres::JSONOpMethods
748
748
  end
749
749
  end
750
750
  end
@@ -188,7 +188,7 @@ end
188
188
  if defined?(Sequel::CoreRefinements)
189
189
  module Sequel::CoreRefinements
190
190
  refine Symbol do
191
- include Sequel::Postgres::RangeOpMethods
191
+ send INCLUDE_METH, Sequel::Postgres::RangeOpMethods
192
192
  end
193
193
  end
194
194
  end
@@ -210,7 +210,7 @@ end
210
210
  if defined?(Sequel::CoreRefinements)
211
211
  module Sequel::CoreRefinements
212
212
  refine Symbol do
213
- include Sequel::Postgres::PGRowOp::ExpressionMethods
213
+ send INCLUDE_METH, Sequel::Postgres::PGRowOp::ExpressionMethods
214
214
  end
215
215
  end
216
216
  end
@@ -51,9 +51,10 @@ module Sequel::S
51
51
 
52
52
  # :nocov:
53
53
  if RUBY_VERSION >= '2.0.0'
54
+ include_meth = RUBY_VERSION >= '3.1' ? :import_methods : :include
54
55
  # :nocov:
55
56
  refine Object do
56
- include Sequel::S
57
+ send include_meth, Sequel::S
57
58
  end
58
59
  end
59
60
  end