sequel 5.48.0 → 5.52.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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +80 -0
  3. data/README.rdoc +12 -5
  4. data/doc/migration.rdoc +1 -1
  5. data/doc/opening_databases.rdoc +1 -1
  6. data/doc/postgresql.rdoc +8 -0
  7. data/doc/release_notes/5.49.0.txt +59 -0
  8. data/doc/release_notes/5.50.0.txt +78 -0
  9. data/doc/release_notes/5.51.0.txt +47 -0
  10. data/doc/release_notes/5.52.0.txt +87 -0
  11. data/doc/testing.rdoc +3 -1
  12. data/lib/sequel/adapters/ado/access.rb +1 -1
  13. data/lib/sequel/adapters/ado.rb +1 -1
  14. data/lib/sequel/adapters/amalgalite.rb +3 -5
  15. data/lib/sequel/adapters/ibmdb.rb +2 -2
  16. data/lib/sequel/adapters/jdbc/derby.rb +3 -0
  17. data/lib/sequel/adapters/jdbc/postgresql.rb +4 -4
  18. data/lib/sequel/adapters/jdbc.rb +9 -11
  19. data/lib/sequel/adapters/mysql.rb +80 -67
  20. data/lib/sequel/adapters/mysql2.rb +42 -44
  21. data/lib/sequel/adapters/odbc.rb +1 -1
  22. data/lib/sequel/adapters/oracle.rb +3 -3
  23. data/lib/sequel/adapters/postgres.rb +27 -29
  24. data/lib/sequel/adapters/shared/access.rb +2 -0
  25. data/lib/sequel/adapters/shared/db2.rb +2 -0
  26. data/lib/sequel/adapters/shared/mysql.rb +4 -2
  27. data/lib/sequel/adapters/shared/postgres.rb +59 -6
  28. data/lib/sequel/adapters/shared/sqlanywhere.rb +3 -0
  29. data/lib/sequel/adapters/shared/sqlite.rb +1 -1
  30. data/lib/sequel/adapters/sqlanywhere.rb +1 -1
  31. data/lib/sequel/adapters/sqlite.rb +16 -18
  32. data/lib/sequel/adapters/tinytds.rb +1 -1
  33. data/lib/sequel/adapters/utils/columns_limit_1.rb +22 -0
  34. data/lib/sequel/ast_transformer.rb +6 -0
  35. data/lib/sequel/connection_pool/sharded_single.rb +5 -7
  36. data/lib/sequel/connection_pool/single.rb +6 -8
  37. data/lib/sequel/core.rb +17 -18
  38. data/lib/sequel/database/connecting.rb +2 -2
  39. data/lib/sequel/database/misc.rb +6 -0
  40. data/lib/sequel/database/query.rb +1 -1
  41. data/lib/sequel/dataset/actions.rb +2 -2
  42. data/lib/sequel/dataset/query.rb +45 -3
  43. data/lib/sequel/dataset/sql.rb +18 -9
  44. data/lib/sequel/extensions/any_not_empty.rb +1 -1
  45. data/lib/sequel/extensions/core_refinements.rb +36 -11
  46. data/lib/sequel/extensions/date_parse_input_handler.rb +67 -0
  47. data/lib/sequel/extensions/datetime_parse_to_time.rb +5 -1
  48. data/lib/sequel/extensions/duplicate_columns_handler.rb +1 -1
  49. data/lib/sequel/extensions/inflector.rb +1 -1
  50. data/lib/sequel/extensions/migration.rb +4 -1
  51. data/lib/sequel/extensions/pagination.rb +1 -1
  52. data/lib/sequel/extensions/pg_array_ops.rb +1 -1
  53. data/lib/sequel/extensions/pg_extended_date_support.rb +1 -1
  54. data/lib/sequel/extensions/pg_hstore_ops.rb +53 -3
  55. data/lib/sequel/extensions/pg_inet_ops.rb +1 -1
  56. data/lib/sequel/extensions/pg_interval.rb +1 -0
  57. data/lib/sequel/extensions/pg_json.rb +3 -5
  58. data/lib/sequel/extensions/pg_json_ops.rb +71 -1
  59. data/lib/sequel/extensions/pg_multirange.rb +372 -0
  60. data/lib/sequel/extensions/pg_range.rb +4 -12
  61. data/lib/sequel/extensions/pg_range_ops.rb +37 -9
  62. data/lib/sequel/extensions/pg_row_ops.rb +1 -1
  63. data/lib/sequel/extensions/s.rb +2 -1
  64. data/lib/sequel/extensions/server_block.rb +8 -12
  65. data/lib/sequel/extensions/sql_comments.rb +108 -3
  66. data/lib/sequel/extensions/sql_log_normalizer.rb +108 -0
  67. data/lib/sequel/extensions/string_agg.rb +1 -1
  68. data/lib/sequel/extensions/string_date_time.rb +19 -23
  69. data/lib/sequel/model/associations.rb +3 -1
  70. data/lib/sequel/model/base.rb +9 -13
  71. data/lib/sequel/model/inflections.rb +1 -1
  72. data/lib/sequel/plugins/auto_validations.rb +25 -5
  73. data/lib/sequel/plugins/column_encryption.rb +1 -1
  74. data/lib/sequel/plugins/composition.rb +1 -0
  75. data/lib/sequel/plugins/json_serializer.rb +2 -2
  76. data/lib/sequel/plugins/lazy_attributes.rb +3 -0
  77. data/lib/sequel/plugins/serialization.rb +1 -0
  78. data/lib/sequel/plugins/serialization_modification_detection.rb +1 -0
  79. data/lib/sequel/plugins/sql_comments.rb +189 -0
  80. data/lib/sequel/plugins/static_cache.rb +1 -1
  81. data/lib/sequel/plugins/subclasses.rb +28 -11
  82. data/lib/sequel/plugins/tactical_eager_loading.rb +8 -2
  83. data/lib/sequel/plugins/unused_associations.rb +2 -2
  84. data/lib/sequel/plugins/update_or_create.rb +1 -1
  85. data/lib/sequel/plugins/validation_helpers.rb +7 -1
  86. data/lib/sequel/plugins/xml_serializer.rb +1 -1
  87. data/lib/sequel/sql.rb +1 -1
  88. data/lib/sequel/timezones.rb +12 -14
  89. data/lib/sequel/version.rb +1 -1
  90. metadata +17 -4
@@ -365,7 +365,7 @@ module Sequel
365
365
  h = {root => h}
366
366
  end
367
367
 
368
- h = yield h if block_given?
368
+ h = yield h if defined?(yield)
369
369
  Sequel.object_to_json(h, *a)
370
370
  end
371
371
 
@@ -441,7 +441,7 @@ module Sequel
441
441
  end
442
442
 
443
443
  res = {collection_root => res} if collection_root
444
- res = yield res if block_given?
444
+ res = yield res if defined?(yield)
445
445
 
446
446
  Sequel.object_to_json(res, *a)
447
447
  end
@@ -52,7 +52,9 @@ module Sequel
52
52
  unless select = dataset.opts[:select]
53
53
  select = dataset.columns.map{|c| Sequel.qualify(dataset.first_source, c)}
54
54
  end
55
+ db_schema = @db_schema
55
56
  set_dataset(dataset.select(*select.reject{|c| attrs.include?(dataset.send(:_hash_key_symbol, c))}))
57
+ @db_schema = db_schema
56
58
  attrs.each{|a| define_lazy_attribute_getter(a)}
57
59
  end
58
60
 
@@ -71,6 +73,7 @@ module Sequel
71
73
  super()
72
74
  end
73
75
  end
76
+ alias_method(a, a)
74
77
  end
75
78
  end
76
79
  end
@@ -184,6 +184,7 @@ module Sequel
184
184
  deserialized_values
185
185
  super
186
186
  deserialized_values.freeze
187
+ self
187
188
  end
188
189
 
189
190
  # Serialize deserialized values before saving
@@ -52,6 +52,7 @@ module Sequel
52
52
  @original_deserialized_values ||= {}
53
53
  super
54
54
  @original_deserialized_values.freeze
55
+ self
55
56
  end
56
57
 
57
58
  private
@@ -0,0 +1,189 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Sequel
4
+ module Plugins
5
+ # The sql_comments plugin will automatically use SQL comments on
6
+ # queries for the model it is loaded into. These comments will
7
+ # show the related model, what type of method was called, and
8
+ # the method name (or association name for queries to load
9
+ # associations):
10
+ #
11
+ # album = Album[1]
12
+ # # SELECT * FROM albums WHERE (id = 1) LIMIT 1
13
+ # # -- model:Album,method_type:class,method:[]
14
+ #
15
+ # album.update(:name=>'A')
16
+ # # UPDATE albums SET name = 'baz' WHERE (id = 1)
17
+ # # -- model:Album,method_type:instance,method:update
18
+ #
19
+ # album.artist
20
+ # # SELECT * FROM artists WHERE (artists.id = 1)
21
+ # # -- model:Album,method_type:association_load,association:artist
22
+ #
23
+ # Album.eager(:artists).all
24
+ # # SELECT * FROM albums
25
+ # # SELECT * FROM artists WHERE (artists.id IN (1))
26
+ # # -- model:Album,method_type:association_eager_load,association:artist
27
+ #
28
+ # Album.where(id: 1).delete
29
+ # # DELETE FROM albums WHERE (id = 1)
30
+ # # -- model:Album,method_type:dataset,method:delete
31
+ #
32
+ # This plugin automatically supports the class, instance, and dataset
33
+ # methods are are supported by default in Sequel::Model. To support
34
+ # custom class, instance, and dataset methods, such as those added by
35
+ # other plugins, you can use the appropriate <tt>sql_comments_*_methods</tt>
36
+ # class method:
37
+ #
38
+ # Album.sql_comments_class_methods :first_by_name # example from finder plugin, with :mod option
39
+ # Album.sql_comments_instance_methods :lazy_attribute_lookup # lazy_attributes plugin
40
+ # Album.sql_comments_dataset_methods :to_csv # csv_serializer plugin
41
+ #
42
+ # In order for the sql_comments plugin to work, the sql_comments
43
+ # Database extension must be loaded into the model's database.
44
+ #
45
+ # Note that in order to make sure SQL comments are included, some
46
+ # optimizations are disabled if this plugin is loaded.
47
+ #
48
+ # Usage:
49
+ #
50
+ # # Make all model subclasses support automatic SQL comments
51
+ # # (called before loading subclasses)
52
+ # Sequel::Model.plugin :sql_comments
53
+ #
54
+ # # Make the Album class support automatic SQL comments
55
+ # Album.plugin :sql_comments
56
+ module SqlComments
57
+ # Define a method +meth+ on the given module +mod+ that will use automatic
58
+ # SQL comments with the given model, method_type, and method.
59
+ def self.def_sql_commend_method(mod, model, method_type, meth)
60
+ mod.send(:define_method, meth) do |*a, &block|
61
+ model.db.with_comments(:model=>model, :method_type=>method_type, :method=>meth) do
62
+ super(*a, &block)
63
+ end
64
+ end
65
+ # :nocov:
66
+ ruby2_keywords(meth) if respond_to?(:ruby2_keywords, false)
67
+ # :nocov:
68
+ end
69
+
70
+ def self.configure(model)
71
+ model.send(:reset_fast_pk_lookup_sql)
72
+ end
73
+
74
+ module ClassMethods
75
+ # Use automatic SQL comments for the given class methods.
76
+ def sql_comments_class_methods(*meths)
77
+ _sql_comments_methods(singleton_class, :class, meths)
78
+ end
79
+
80
+ # Use automatic SQL comments for the given instance methods.
81
+ def sql_comments_instance_methods(*meths)
82
+ _sql_comments_methods(self, :instance, meths)
83
+ end
84
+
85
+ # Use automatic SQL comments for the given dataset methods.
86
+ def sql_comments_dataset_methods(*meths)
87
+ unless @_sql_comments_dataset_module
88
+ dataset_module(@_sql_comments_dataset_module = Module.new)
89
+ end
90
+ _sql_comments_methods(@_sql_comments_dataset_module, :dataset, meths)
91
+ end
92
+
93
+ [:[], :create, :find, :find_or_create, :with_pk, :with_pk!].each do |meth|
94
+ define_method(meth) do |*a, &block|
95
+ db.with_comments(:model=>self, :method_type=>:class, :method=>meth) do
96
+ super(*a, &block)
97
+ end
98
+ end
99
+ # :nocov:
100
+ ruby2_keywords(meth) if respond_to?(:ruby2_keywords, false)
101
+ # :nocov:
102
+ end
103
+
104
+ private
105
+
106
+ # Don't optimize the fast PK lookups, as it uses static SQL that
107
+ # won't support the SQL comments.
108
+ def reset_fast_pk_lookup_sql
109
+ @fast_pk_lookup_sql = @fast_instance_delete_sql = nil
110
+ end
111
+
112
+ # Define automatic SQL comment methods in +mod+ for each method in +meths+,
113
+ # with the given +method_type+.
114
+ def _sql_comments_methods(mod, method_type, meths)
115
+ meths.each do |meth|
116
+ SqlComments.def_sql_commend_method(mod, self, method_type, meth)
117
+ end
118
+ end
119
+ end
120
+
121
+ module InstanceMethods
122
+ [:delete, :destroy, :lock!, :refresh, :save, :save_changes, :update, :update_fields].each do |meth|
123
+ define_method(meth) do |*a, &block|
124
+ t = Sequel.current
125
+ return super(*a, &block) if (hash = Sequel.synchronize{db.comment_hashes[t]}) && hash[:model]
126
+
127
+ db.with_comments(:model=>model, :method_type=>:instance, :method=>meth) do
128
+ super(*a, &block)
129
+ end
130
+ end
131
+ # :nocov:
132
+ ruby2_keywords(meth) if respond_to?(:ruby2_keywords, false)
133
+ # :nocov:
134
+ end
135
+
136
+ private
137
+
138
+ # Do not use a placeholder loader for associations.
139
+ def _associated_object_loader(opts, dynamic_opts)
140
+ nil
141
+ end
142
+
143
+ # Use SQL comments on normal association load queries, showing they are association loads.
144
+ def _load_associated_objects(opts, dynamic_opts=OPTS)
145
+ db.with_comments(:model=>model, :method_type=>:association_load, :association=>opts[:name]) do
146
+ super
147
+ end
148
+ end
149
+ end
150
+
151
+ module DatasetMethods
152
+ Dataset::ACTION_METHODS.each do |meth|
153
+ define_method(meth) do |*a, &block|
154
+ t = Sequel.current
155
+ return super(*a, &block) if (hash = Sequel.synchronize{db.comment_hashes[t]}) && hash[:model]
156
+
157
+ db.with_comments(:model=>model, :method_type=>:dataset, :method=>meth) do
158
+ super(*a, &block)
159
+ end
160
+ end
161
+ # :nocov:
162
+ ruby2_keywords(meth) if respond_to?(:ruby2_keywords, false)
163
+ # :nocov:
164
+ end
165
+
166
+ private
167
+
168
+ # Add the association name as part of the eager load data, so
169
+ # perform_eager_load has access to it.
170
+ def prepare_eager_load(a, reflections, eager_assoc)
171
+ res = super
172
+
173
+ reflections.each do |r|
174
+ res[r[:eager_loader]][:association] = r[:name]
175
+ end
176
+
177
+ res
178
+ end
179
+
180
+ # Use SQL comments on eager load queries, showing they are eager loads.
181
+ def perform_eager_load(loader, eo)
182
+ db.with_comments(:model=>model, :method_type=>:association_eager_load, :method=>nil, :association=>eo[:association]) do
183
+ super
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
189
+ end
@@ -87,7 +87,7 @@ module Sequel
87
87
  # array containing the number of instances specified (single integer
88
88
  # argument).
89
89
  def first(*args)
90
- if block_given? || args.length > 1 || (args.length == 1 && !args[0].is_a?(Integer))
90
+ if defined?(yield) || args.length > 1 || (args.length == 1 && !args[0].is_a?(Integer))
91
91
  super
92
92
  else
93
93
  @all.first(*args)
@@ -5,7 +5,7 @@ module Sequel
5
5
  # The subclasses plugin keeps track of all subclasses of the
6
6
  # current model class. Direct subclasses are available via the
7
7
  # subclasses method, and all descendent classes are available via the
8
- # descendents method:
8
+ # descendants method:
9
9
  #
10
10
  # c = Class.new(Sequel::Model)
11
11
  # c.plugin :subclasses
@@ -16,7 +16,7 @@ module Sequel
16
16
  # sc1.subclasses # [ssc1]
17
17
  # sc2.subclasses # []
18
18
  # ssc1.subclasses # []
19
- # c.descendents # [sc1, ssc1, sc2]
19
+ # c.descendants # [sc1, ssc1, sc2]
20
20
  #
21
21
  # You can also finalize the associations and then freeze the classes
22
22
  # in all descendent classes. Doing so is a recommended practice after
@@ -35,9 +35,14 @@ module Sequel
35
35
  # class B < Sequel::Model; end
36
36
  # a # => [A, B]
37
37
  module Subclasses
38
+ NEED_SUBCLASSES = !Object.respond_to?(:subclasses)
39
+ private_constant :NEED_SUBCLASSES
40
+
38
41
  # Initialize the subclasses instance variable for the model.
39
42
  def self.apply(model, &block)
40
- model.instance_variable_set(:@subclasses, [])
43
+ # :nocov:
44
+ model.instance_variable_set(:@subclasses, []) if NEED_SUBCLASSES
45
+ # :nocov:
41
46
  model.instance_variable_set(:@on_subclass, block)
42
47
  end
43
48
 
@@ -46,21 +51,31 @@ module Sequel
46
51
  # class created.
47
52
  attr_reader :on_subclass
48
53
 
49
- # All subclasses for the current model. Does not
50
- # include the model itself.
51
- attr_reader :subclasses
54
+ # :nocov:
55
+ if NEED_SUBCLASSES
56
+ # All subclasses for the current model. Does not
57
+ # include the model itself.
58
+ attr_reader :subclasses
59
+ end
60
+ # :nocov:
52
61
 
53
62
  # All descendent classes of this model.
54
- def descendents
55
- Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendents)}.flatten
63
+ def descendants
64
+ Sequel.synchronize{subclasses.dup}.map{|x| [x] + x.send(:descendants)}.flatten
56
65
  end
57
66
 
67
+ # SEQUEL6: Remove
68
+ alias descendents descendants
69
+
58
70
  # Freeze all descendent classes. This also finalizes the associations for those
59
71
  # classes before freezing.
60
- def freeze_descendents
61
- descendents.each(&:finalize_associations).each(&:freeze)
72
+ def freeze_descendants
73
+ descendants.each(&:finalize_associations).each(&:freeze)
62
74
  end
63
75
 
76
+ # SEQUEL6: Remove
77
+ alias freeze_descendents freeze_descendants
78
+
64
79
  Plugins.inherited_instance_variables(self, :@subclasses=>lambda{|v| []}, :@on_subclass=>nil)
65
80
 
66
81
  private
@@ -70,7 +85,9 @@ module Sequel
70
85
  # in the subclass.
71
86
  def inherited(subclass)
72
87
  super
73
- Sequel.synchronize{subclasses << subclass}
88
+ # :nocov:
89
+ Sequel.synchronize{subclasses << subclass} if NEED_SUBCLASSES
90
+ # :nocov:
74
91
  on_subclass.call(subclass) if on_subclass
75
92
  end
76
93
  end
@@ -143,9 +143,15 @@ module Sequel
143
143
  def load_associated_objects(opts, dynamic_opts=OPTS, &block)
144
144
  dynamic_opts = load_association_objects_options(dynamic_opts, &block)
145
145
  name = opts[:name]
146
- if (!associations.include?(name) || dynamic_opts[:eager_reload]) && opts[:allow_eager] != false && retrieved_by && !frozen? && !dynamic_opts[:callback] && !dynamic_opts[:reload]
146
+ eager_reload = dynamic_opts[:eager_reload]
147
+ if (!associations.include?(name) || eager_reload) && opts[:allow_eager] != false && retrieved_by && !frozen? && !dynamic_opts[:callback] && !dynamic_opts[:reload]
147
148
  begin
148
- retrieved_by.send(:eager_load, retrieved_with.reject(&:frozen?), name=>dynamic_opts[:eager] || OPTS)
149
+ objects = if eager_reload
150
+ retrieved_with.reject(&:frozen?)
151
+ else
152
+ retrieved_with.reject{|x| x.frozen? || x.associations.include?(name)}
153
+ end
154
+ retrieved_by.send(:eager_load, objects, name=>dynamic_opts[:eager] || OPTS)
149
155
  rescue Sequel::UndefinedAssociation
150
156
  # This can happen if class table inheritance is used and the association
151
157
  # is only defined in a subclass. This particular instance can use the
@@ -313,7 +313,7 @@ module Sequel
313
313
  {}
314
314
  end
315
315
 
316
- ([self] + descendents).each do |sc|
316
+ ([self] + descendants).each do |sc|
317
317
  next if sc.associations.empty? || !sc.name
318
318
  module_mapping[sc.send(:overridable_methods_module)] = sc
319
319
  cov_data = coverage_data[sc.name] ||= {''=>[]}
@@ -348,7 +348,7 @@ module Sequel
348
348
 
349
349
  unused_associations_data = {}
350
350
 
351
- ([self] + descendents).each do |sc|
351
+ ([self] + descendants).each do |sc|
352
352
  next unless cov_data = coverage_data[sc.name]
353
353
  reflection_data = cov_data[''] || []
354
354
 
@@ -55,7 +55,7 @@ module Sequel
55
55
  def find_or_new(attrs, set_attrs=nil)
56
56
  obj = find(attrs) || new(attrs)
57
57
  obj.set(set_attrs) if set_attrs
58
- yield obj if block_given?
58
+ yield obj if defined?(yield)
59
59
  obj
60
60
  end
61
61
  end
@@ -85,6 +85,7 @@ module Sequel
85
85
  :max_length=>{:message=>lambda{|max| "is longer than #{max} characters"}, :nil_message=>lambda{"is not present"}},
86
86
  :min_length=>{:message=>lambda{|min| "is shorter than #{min} characters"}},
87
87
  :not_null=>{:message=>lambda{"is not present"}},
88
+ :no_null_byte=>{:message=>lambda{"contains a null byte"}},
88
89
  :numeric=>{:message=>lambda{"is not a number"}},
89
90
  :operator=>{:message=>lambda{|operator, rhs| "is not #{operator} #{rhs}"}},
90
91
  :type=>{:message=>lambda{|klass| klass.is_a?(Array) ? "is not a valid #{klass.join(" or ").downcase}" : "is not a valid #{klass.to_s.downcase}"}},
@@ -149,6 +150,11 @@ module Sequel
149
150
  def validates_not_null(atts, opts=OPTS)
150
151
  validatable_attributes_for_type(:not_null, atts, opts){|a,v,m| validation_error_message(m) if v.nil?}
151
152
  end
153
+
154
+ # Check attribute value(s) does not contain a null ("\0", ASCII NUL) byte.
155
+ def validates_no_null_byte(atts, opts=OPTS)
156
+ validatable_attributes_for_type(:no_null_byte, atts, opts){|a,v,m| validation_error_message(m) if String === v && v.include?("\0")}
157
+ end
152
158
 
153
159
  # Check attribute value(s) string representation is a valid float.
154
160
  def validates_numeric(atts, opts=OPTS)
@@ -260,7 +266,7 @@ module Sequel
260
266
  next if vals.any?(&:nil?)
261
267
  ds.where(arr.zip(vals))
262
268
  end
263
- ds = yield(ds) if block_given?
269
+ ds = yield(ds) if defined?(yield)
264
270
  unless new?
265
271
  h = ds.joined_dataset? ? qualified_pk_hash : pk_hash
266
272
  ds = ds.exclude(h)
@@ -359,7 +359,7 @@ module Sequel
359
359
  else
360
360
  Array(inc).each{|i| to_xml_include(x1, i)}
361
361
  end
362
- yield x1 if block_given?
362
+ yield x1 if defined?(yield)
363
363
  end
364
364
  x.to_xml
365
365
  end
data/lib/sequel/sql.rb CHANGED
@@ -467,7 +467,7 @@ module Sequel
467
467
  #
468
468
  # Sequel[1] - :a # SQL: (1 - a)
469
469
  def expr(arg=(no_arg=true), &block)
470
- if block_given?
470
+ if defined?(yield)
471
471
  if no_arg
472
472
  return expr(block)
473
473
  else
@@ -82,22 +82,20 @@ module Sequel
82
82
  # +application_timezone+ using +convert_input_timestamp+ and
83
83
  # +convert_output_timestamp+.
84
84
  def convert_timestamp(v, input_timezone)
85
- begin
86
- if v.is_a?(Date) && !v.is_a?(DateTime)
87
- # Dates handled specially as they are assumed to already be in the application_timezone
88
- if datetime_class == DateTime
89
- DateTime.civil(v.year, v.month, v.day, 0, 0, 0, application_timezone == :local ? Rational(Time.local(v.year, v.month, v.day).utc_offset, 86400) : 0)
90
- else
91
- Time.public_send(application_timezone == :utc ? :utc : :local, v.year, v.month, v.day)
92
- end
85
+ if v.is_a?(Date) && !v.is_a?(DateTime)
86
+ # Dates handled specially as they are assumed to already be in the application_timezone
87
+ if datetime_class == DateTime
88
+ DateTime.civil(v.year, v.month, v.day, 0, 0, 0, application_timezone == :local ? Rational(Time.local(v.year, v.month, v.day).utc_offset, 86400) : 0)
93
89
  else
94
- convert_output_timestamp(convert_input_timestamp(v, input_timezone), application_timezone)
90
+ Time.public_send(application_timezone == :utc ? :utc : :local, v.year, v.month, v.day)
95
91
  end
96
- rescue InvalidValue
97
- raise
98
- rescue => e
99
- raise convert_exception_class(e, InvalidValue)
92
+ else
93
+ convert_output_timestamp(convert_input_timestamp(v, input_timezone), application_timezone)
100
94
  end
95
+ rescue InvalidValue
96
+ raise
97
+ rescue => e
98
+ raise convert_exception_class(e, InvalidValue)
101
99
  end
102
100
 
103
101
  # Convert the given object into an object of <tt>Sequel.datetime_class</tt> in the
@@ -158,7 +156,7 @@ module Sequel
158
156
  case v
159
157
  when String
160
158
  v2 = Sequel.string_to_datetime(v)
161
- if !input_timezone || Date._parse(v).has_key?(:offset)
159
+ if !input_timezone || _date_parse(v).has_key?(:offset)
162
160
  v2
163
161
  else
164
162
  # Correct for potentially wrong offset if string doesn't include offset
@@ -6,7 +6,7 @@ module Sequel
6
6
 
7
7
  # The minor version of Sequel. Bumped for every non-patch level
8
8
  # release, generally around once a month.
9
- MINOR = 48
9
+ MINOR = 52
10
10
 
11
11
  # The tiny version of Sequel. Usually 0, only bumped for bugfix
12
12
  # releases that fix regressions from previous versions.
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.48.0
4
+ version: 5.52.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-01 00:00:00.000000000 Z
11
+ date: 2022-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -192,7 +192,11 @@ extra_rdoc_files:
192
192
  - doc/release_notes/5.46.0.txt
193
193
  - doc/release_notes/5.47.0.txt
194
194
  - doc/release_notes/5.48.0.txt
195
+ - doc/release_notes/5.49.0.txt
195
196
  - doc/release_notes/5.5.0.txt
197
+ - doc/release_notes/5.50.0.txt
198
+ - doc/release_notes/5.51.0.txt
199
+ - doc/release_notes/5.52.0.txt
196
200
  - doc/release_notes/5.6.0.txt
197
201
  - doc/release_notes/5.7.0.txt
198
202
  - doc/release_notes/5.8.0.txt
@@ -268,7 +272,11 @@ files:
268
272
  - doc/release_notes/5.46.0.txt
269
273
  - doc/release_notes/5.47.0.txt
270
274
  - doc/release_notes/5.48.0.txt
275
+ - doc/release_notes/5.49.0.txt
271
276
  - doc/release_notes/5.5.0.txt
277
+ - doc/release_notes/5.50.0.txt
278
+ - doc/release_notes/5.51.0.txt
279
+ - doc/release_notes/5.52.0.txt
272
280
  - doc/release_notes/5.6.0.txt
273
281
  - doc/release_notes/5.7.0.txt
274
282
  - doc/release_notes/5.8.0.txt
@@ -323,6 +331,7 @@ files:
323
331
  - lib/sequel/adapters/sqlanywhere.rb
324
332
  - lib/sequel/adapters/sqlite.rb
325
333
  - lib/sequel/adapters/tinytds.rb
334
+ - lib/sequel/adapters/utils/columns_limit_1.rb
326
335
  - lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb
327
336
  - lib/sequel/adapters/utils/emulate_offset_with_row_number.rb
328
337
  - lib/sequel/adapters/utils/mysql_mysql2.rb
@@ -380,6 +389,7 @@ files:
380
389
  - lib/sequel/extensions/current_datetime_timestamp.rb
381
390
  - lib/sequel/extensions/dataset_source_alias.rb
382
391
  - lib/sequel/extensions/date_arithmetic.rb
392
+ - lib/sequel/extensions/date_parse_input_handler.rb
383
393
  - lib/sequel/extensions/datetime_parse_to_time.rb
384
394
  - lib/sequel/extensions/duplicate_columns_handler.rb
385
395
  - lib/sequel/extensions/empty_array_consider_nulls.rb
@@ -415,6 +425,7 @@ files:
415
425
  - lib/sequel/extensions/pg_json.rb
416
426
  - lib/sequel/extensions/pg_json_ops.rb
417
427
  - lib/sequel/extensions/pg_loose_count.rb
428
+ - lib/sequel/extensions/pg_multirange.rb
418
429
  - lib/sequel/extensions/pg_range.rb
419
430
  - lib/sequel/extensions/pg_range_ops.rb
420
431
  - lib/sequel/extensions/pg_row.rb
@@ -435,6 +446,7 @@ files:
435
446
  - lib/sequel/extensions/split_array_nil.rb
436
447
  - lib/sequel/extensions/sql_comments.rb
437
448
  - lib/sequel/extensions/sql_expr.rb
449
+ - lib/sequel/extensions/sql_log_normalizer.rb
438
450
  - lib/sequel/extensions/string_agg.rb
439
451
  - lib/sequel/extensions/string_date_time.rb
440
452
  - lib/sequel/extensions/symbol_aref.rb
@@ -521,6 +533,7 @@ files:
521
533
  - lib/sequel/plugins/skip_create_refresh.rb
522
534
  - lib/sequel/plugins/skip_saving_columns.rb
523
535
  - lib/sequel/plugins/split_values.rb
536
+ - lib/sequel/plugins/sql_comments.rb
524
537
  - lib/sequel/plugins/static_cache.rb
525
538
  - lib/sequel/plugins/static_cache_cache.rb
526
539
  - lib/sequel/plugins/string_stripper.rb
@@ -555,7 +568,7 @@ metadata:
555
568
  bug_tracker_uri: https://github.com/jeremyevans/sequel/issues
556
569
  changelog_uri: http://sequel.jeremyevans.net/rdoc/files/CHANGELOG.html
557
570
  documentation_uri: http://sequel.jeremyevans.net/documentation.html
558
- mailing_list_uri: https://groups.google.com/forum/#!forum/sequel-talk
571
+ mailing_list_uri: https://github.com/jeremyevans/sequel/discussions
559
572
  source_code_uri: https://github.com/jeremyevans/sequel
560
573
  post_install_message:
561
574
  rdoc_options:
@@ -579,7 +592,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
579
592
  - !ruby/object:Gem::Version
580
593
  version: '0'
581
594
  requirements: []
582
- rubygems_version: 3.2.22
595
+ rubygems_version: 3.3.3
583
596
  signing_key:
584
597
  specification_version: 4
585
598
  summary: The Database Toolkit for Ruby