sequel 5.61.0 → 5.63.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/CHANGELOG +46 -0
- data/README.rdoc +20 -19
- data/doc/advanced_associations.rdoc +13 -13
- data/doc/association_basics.rdoc +21 -15
- data/doc/cheat_sheet.rdoc +3 -3
- data/doc/model_hooks.rdoc +1 -1
- data/doc/object_model.rdoc +8 -8
- data/doc/opening_databases.rdoc +4 -4
- data/doc/postgresql.rdoc +8 -8
- data/doc/querying.rdoc +1 -1
- data/doc/release_notes/5.62.0.txt +132 -0
- data/doc/release_notes/5.63.0.txt +33 -0
- data/doc/schema_modification.rdoc +1 -1
- data/doc/security.rdoc +9 -9
- data/doc/sql.rdoc +13 -13
- data/doc/testing.rdoc +13 -11
- data/doc/transactions.rdoc +6 -6
- data/doc/virtual_rows.rdoc +1 -1
- data/lib/sequel/adapters/postgres.rb +4 -0
- data/lib/sequel/adapters/shared/access.rb +9 -1
- data/lib/sequel/adapters/shared/mssql.rb +9 -5
- data/lib/sequel/adapters/shared/mysql.rb +7 -0
- data/lib/sequel/adapters/shared/oracle.rb +7 -0
- data/lib/sequel/adapters/shared/postgres.rb +275 -152
- data/lib/sequel/adapters/shared/sqlanywhere.rb +7 -0
- data/lib/sequel/adapters/shared/sqlite.rb +5 -0
- data/lib/sequel/connection_pool/sharded_threaded.rb +5 -1
- data/lib/sequel/connection_pool/threaded.rb +8 -8
- data/lib/sequel/connection_pool/timed_queue.rb +257 -0
- data/lib/sequel/connection_pool.rb +47 -30
- data/lib/sequel/database/connecting.rb +24 -0
- data/lib/sequel/database/misc.rb +8 -2
- data/lib/sequel/database/query.rb +37 -0
- data/lib/sequel/dataset/actions.rb +56 -11
- data/lib/sequel/dataset/features.rb +5 -0
- data/lib/sequel/dataset/misc.rb +1 -1
- data/lib/sequel/dataset/query.rb +9 -9
- data/lib/sequel/dataset/sql.rb +5 -1
- data/lib/sequel/extensions/_model_pg_row.rb +0 -12
- data/lib/sequel/extensions/_pretty_table.rb +1 -1
- data/lib/sequel/extensions/async_thread_pool.rb +11 -11
- data/lib/sequel/extensions/auto_literal_strings.rb +1 -1
- data/lib/sequel/extensions/constraint_validations.rb +1 -1
- data/lib/sequel/extensions/date_arithmetic.rb +1 -1
- data/lib/sequel/extensions/migration.rb +1 -1
- data/lib/sequel/extensions/named_timezones.rb +21 -5
- data/lib/sequel/extensions/pg_array.rb +22 -3
- data/lib/sequel/extensions/pg_auto_parameterize.rb +478 -0
- data/lib/sequel/extensions/pg_extended_date_support.rb +12 -0
- data/lib/sequel/extensions/pg_extended_integer_support.rb +116 -0
- data/lib/sequel/extensions/pg_hstore.rb +5 -0
- data/lib/sequel/extensions/pg_inet.rb +9 -10
- data/lib/sequel/extensions/pg_interval.rb +9 -10
- data/lib/sequel/extensions/pg_json.rb +10 -10
- data/lib/sequel/extensions/pg_multirange.rb +5 -10
- data/lib/sequel/extensions/pg_range.rb +5 -10
- data/lib/sequel/extensions/pg_row.rb +18 -13
- data/lib/sequel/model/associations.rb +9 -4
- data/lib/sequel/model/base.rb +6 -5
- data/lib/sequel/plugins/auto_validations.rb +53 -15
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
- data/lib/sequel/plugins/composition.rb +2 -2
- data/lib/sequel/plugins/concurrent_eager_loading.rb +4 -4
- data/lib/sequel/plugins/dirty.rb +1 -1
- data/lib/sequel/plugins/finder.rb +3 -1
- data/lib/sequel/plugins/nested_attributes.rb +4 -4
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +1 -1
- data/lib/sequel/plugins/primary_key_lookup_check_values.rb +154 -0
- data/lib/sequel/plugins/single_table_inheritance.rb +8 -0
- data/lib/sequel/plugins/sql_comments.rb +1 -1
- data/lib/sequel/plugins/tactical_eager_loading.rb +14 -14
- data/lib/sequel/plugins/validate_associated.rb +22 -12
- data/lib/sequel/plugins/validation_helpers.rb +20 -0
- data/lib/sequel/version.rb +1 -1
- metadata +14 -6
|
@@ -253,6 +253,14 @@ module Sequel
|
|
|
253
253
|
|
|
254
254
|
private
|
|
255
255
|
|
|
256
|
+
# Limit tactical eager loading objects to objects that support the same association.
|
|
257
|
+
def _filter_tactical_eager_load_objects(opts)
|
|
258
|
+
objects = defined?(super) ? super : retrieved_with.dup
|
|
259
|
+
name = opts[:name]
|
|
260
|
+
objects.select!{|x| x.model.association_reflections.include?(name)}
|
|
261
|
+
objects
|
|
262
|
+
end
|
|
263
|
+
|
|
256
264
|
# Don't allow use of prepared statements.
|
|
257
265
|
def use_prepared_statements_for?(type)
|
|
258
266
|
false
|
|
@@ -12,7 +12,7 @@ module Sequel
|
|
|
12
12
|
# # SELECT * FROM albums WHERE (id = 1) LIMIT 1
|
|
13
13
|
# # -- model:Album,method_type:class,method:[]
|
|
14
14
|
#
|
|
15
|
-
# album.update(:
|
|
15
|
+
# album.update(name: 'A')
|
|
16
16
|
# # UPDATE albums SET name = 'baz' WHERE (id = 1)
|
|
17
17
|
# # -- model:Album,method_type:instance,method:update
|
|
18
18
|
#
|
|
@@ -152,23 +152,23 @@ module Sequel
|
|
|
152
152
|
name = opts[:name]
|
|
153
153
|
eager_reload = dynamic_opts[:eager_reload]
|
|
154
154
|
if (!associations.include?(name) || eager_reload) && opts[:allow_eager] != false && retrieved_by && !frozen? && !dynamic_opts[:callback] && !dynamic_opts[:reload]
|
|
155
|
-
|
|
156
|
-
objects = if eager_reload
|
|
157
|
-
retrieved_with.reject(&:frozen?)
|
|
158
|
-
else
|
|
159
|
-
retrieved_with.reject{|x| x.frozen? || x.associations.include?(name)}
|
|
160
|
-
end
|
|
161
|
-
retrieved_by.send(:eager_load, objects, name=>dynamic_opts[:eager] || OPTS)
|
|
162
|
-
rescue Sequel::UndefinedAssociation
|
|
163
|
-
# This can happen if class table inheritance is used and the association
|
|
164
|
-
# is only defined in a subclass. This particular instance can use the
|
|
165
|
-
# association, but it can't be eagerly loaded as the parent class doesn't
|
|
166
|
-
# have access to the association, and that's the class doing the eager loading.
|
|
167
|
-
nil
|
|
168
|
-
end
|
|
155
|
+
retrieved_by.send(:eager_load, _filter_tactical_eager_load_objects(:eager_reload=>eager_reload, :name=>name), {name=>dynamic_opts[:eager] || OPTS}, model)
|
|
169
156
|
end
|
|
170
157
|
super
|
|
171
158
|
end
|
|
159
|
+
|
|
160
|
+
# Filter the objects used when tactical eager loading.
|
|
161
|
+
# By default, this removes frozen objects and objects that alreayd have the association loaded
|
|
162
|
+
def _filter_tactical_eager_load_objects(opts)
|
|
163
|
+
objects = defined?(super) ? super : retrieved_with.dup
|
|
164
|
+
if opts[:eager_reload]
|
|
165
|
+
objects.reject!(&:frozen?)
|
|
166
|
+
else
|
|
167
|
+
name = opts[:name]
|
|
168
|
+
objects.reject!{|x| x.frozen? || x.associations.include?(name)}
|
|
169
|
+
end
|
|
170
|
+
objects
|
|
171
|
+
end
|
|
172
172
|
end
|
|
173
173
|
|
|
174
174
|
module DatasetMethods
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Sequel
|
|
4
4
|
module Plugins
|
|
5
|
-
# The
|
|
5
|
+
# The validate_associated plugin allows you to validate associated
|
|
6
6
|
# objects. It also offers the ability to delay the validation of
|
|
7
7
|
# associated objects until the current object is validated.
|
|
8
8
|
# If the associated object is invalid, validation error messages
|
|
@@ -54,22 +54,32 @@ module Sequel
|
|
|
54
54
|
return if reflection[:validate] == false
|
|
55
55
|
association = reflection[:name]
|
|
56
56
|
if (reflection[:type] == :one_to_many || reflection[:type] == :one_to_one) && (key = reflection[:key]).is_a?(Symbol) && !(pk_val = obj.values[key])
|
|
57
|
-
# There could be a presence validation on the foreign key in the associated model,
|
|
58
|
-
# which will fail if we validate before saving the current object. If there is
|
|
59
|
-
# no value for the foreign key, set it to the current primary key value, or a dummy
|
|
60
|
-
# value of 0 if we haven't saved the current object.
|
|
61
57
|
p_key = pk unless pk.is_a?(Array)
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
if p_key
|
|
59
|
+
obj.values[key] = p_key
|
|
60
|
+
else
|
|
61
|
+
ignore_key_errors = true
|
|
62
|
+
end
|
|
64
63
|
end
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
|
|
65
|
+
unless obj.valid?
|
|
66
|
+
if ignore_key_errors
|
|
67
|
+
# Ignore errors on the key column in the associated object. This column
|
|
68
|
+
# will be set when saving to a presumably valid value using a column
|
|
69
|
+
# in the current object (which may not be available until after the current
|
|
70
|
+
# object is saved).
|
|
71
|
+
obj.errors.delete(key)
|
|
72
|
+
obj.errors.delete_if{|k,| Array === k && k.include?(key)}
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
obj.errors.full_messages.each do |m|
|
|
76
|
+
errors.add(association, m)
|
|
77
|
+
end
|
|
69
78
|
end
|
|
79
|
+
|
|
80
|
+
nil
|
|
70
81
|
end
|
|
71
82
|
end
|
|
72
83
|
end
|
|
73
84
|
end
|
|
74
85
|
end
|
|
75
|
-
|
|
@@ -83,7 +83,9 @@ module Sequel
|
|
|
83
83
|
:integer=>{:message=>lambda{"is not a number"}},
|
|
84
84
|
:length_range=>{:message=>lambda{|range| "is too short or too long"}},
|
|
85
85
|
:max_length=>{:message=>lambda{|max| "is longer than #{max} characters"}, :nil_message=>lambda{"is not present"}},
|
|
86
|
+
:max_value=>{:message=>lambda{|max| "is greater than maximum allowed value"}},
|
|
86
87
|
:min_length=>{:message=>lambda{|min| "is shorter than #{min} characters"}},
|
|
88
|
+
:min_value=>{:message=>lambda{|min| "is less than minimum allowed value"}},
|
|
87
89
|
:not_null=>{:message=>lambda{"is not present"}},
|
|
88
90
|
:no_null_byte=>{:message=>lambda{"contains a null byte"}},
|
|
89
91
|
:numeric=>{:message=>lambda{"is not a number"}},
|
|
@@ -141,11 +143,29 @@ module Sequel
|
|
|
141
143
|
end
|
|
142
144
|
end
|
|
143
145
|
|
|
146
|
+
# Check that the attribute values are not greater that the given maximum value.
|
|
147
|
+
# Does not perform validation if attribute value is nil.
|
|
148
|
+
# You should only call this if you have checked the attribute value has the expected type.
|
|
149
|
+
def validates_max_value(max, atts, opts=OPTS)
|
|
150
|
+
validatable_attributes_for_type(:max_value, atts, opts) do |a,v,m|
|
|
151
|
+
validation_error_message(m, max) if !v.nil? && v > max
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
144
155
|
# Check that the attribute values are not shorter than the given min length.
|
|
145
156
|
def validates_min_length(min, atts, opts=OPTS)
|
|
146
157
|
validatable_attributes_for_type(:min_length, atts, opts){|a,v,m| validation_error_message(m, min) if v.nil? || v.length < min}
|
|
147
158
|
end
|
|
148
159
|
|
|
160
|
+
# Check that the attribute values are not less that the given minimum value.
|
|
161
|
+
# Does not perform validation if attribute value is nil.
|
|
162
|
+
# You should only call this if you have checked the attribute value has the expected type.
|
|
163
|
+
def validates_min_value(min, atts, opts=OPTS)
|
|
164
|
+
validatable_attributes_for_type(:min_value, atts, opts) do |a,v,m|
|
|
165
|
+
validation_error_message(m, min) if !v.nil? && v < min
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
149
169
|
# Check attribute value(s) are not NULL/nil.
|
|
150
170
|
def validates_not_null(atts, opts=OPTS)
|
|
151
171
|
validatable_attributes_for_type(:not_null, atts, opts){|a,v,m| validation_error_message(m) if v.nil?}
|
data/lib/sequel/version.rb
CHANGED
|
@@ -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 =
|
|
9
|
+
MINOR = 63
|
|
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.
|
|
4
|
+
version: 5.63.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Evans
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-12-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -193,6 +193,8 @@ extra_rdoc_files:
|
|
|
193
193
|
- doc/release_notes/5.6.0.txt
|
|
194
194
|
- doc/release_notes/5.60.0.txt
|
|
195
195
|
- doc/release_notes/5.61.0.txt
|
|
196
|
+
- doc/release_notes/5.62.0.txt
|
|
197
|
+
- doc/release_notes/5.63.0.txt
|
|
196
198
|
- doc/release_notes/5.7.0.txt
|
|
197
199
|
- doc/release_notes/5.8.0.txt
|
|
198
200
|
- doc/release_notes/5.9.0.txt
|
|
@@ -282,6 +284,8 @@ files:
|
|
|
282
284
|
- doc/release_notes/5.6.0.txt
|
|
283
285
|
- doc/release_notes/5.60.0.txt
|
|
284
286
|
- doc/release_notes/5.61.0.txt
|
|
287
|
+
- doc/release_notes/5.62.0.txt
|
|
288
|
+
- doc/release_notes/5.63.0.txt
|
|
285
289
|
- doc/release_notes/5.7.0.txt
|
|
286
290
|
- doc/release_notes/5.8.0.txt
|
|
287
291
|
- doc/release_notes/5.9.0.txt
|
|
@@ -350,6 +354,7 @@ files:
|
|
|
350
354
|
- lib/sequel/connection_pool/sharded_threaded.rb
|
|
351
355
|
- lib/sequel/connection_pool/single.rb
|
|
352
356
|
- lib/sequel/connection_pool/threaded.rb
|
|
357
|
+
- lib/sequel/connection_pool/timed_queue.rb
|
|
353
358
|
- lib/sequel/core.rb
|
|
354
359
|
- lib/sequel/database.rb
|
|
355
360
|
- lib/sequel/database/connecting.rb
|
|
@@ -420,8 +425,10 @@ files:
|
|
|
420
425
|
- lib/sequel/extensions/pagination.rb
|
|
421
426
|
- lib/sequel/extensions/pg_array.rb
|
|
422
427
|
- lib/sequel/extensions/pg_array_ops.rb
|
|
428
|
+
- lib/sequel/extensions/pg_auto_parameterize.rb
|
|
423
429
|
- lib/sequel/extensions/pg_enum.rb
|
|
424
430
|
- lib/sequel/extensions/pg_extended_date_support.rb
|
|
431
|
+
- lib/sequel/extensions/pg_extended_integer_support.rb
|
|
425
432
|
- lib/sequel/extensions/pg_hstore.rb
|
|
426
433
|
- lib/sequel/extensions/pg_hstore_ops.rb
|
|
427
434
|
- lib/sequel/extensions/pg_inet.rb
|
|
@@ -532,6 +539,7 @@ files:
|
|
|
532
539
|
- lib/sequel/plugins/pg_row.rb
|
|
533
540
|
- lib/sequel/plugins/prepared_statements.rb
|
|
534
541
|
- lib/sequel/plugins/prepared_statements_safe.rb
|
|
542
|
+
- lib/sequel/plugins/primary_key_lookup_check_values.rb
|
|
535
543
|
- lib/sequel/plugins/rcte_tree.rb
|
|
536
544
|
- lib/sequel/plugins/require_valid_schema.rb
|
|
537
545
|
- lib/sequel/plugins/serialization.rb
|
|
@@ -579,7 +587,7 @@ metadata:
|
|
|
579
587
|
documentation_uri: https://sequel.jeremyevans.net/documentation.html
|
|
580
588
|
mailing_list_uri: https://github.com/jeremyevans/sequel/discussions
|
|
581
589
|
source_code_uri: https://github.com/jeremyevans/sequel
|
|
582
|
-
post_install_message:
|
|
590
|
+
post_install_message:
|
|
583
591
|
rdoc_options:
|
|
584
592
|
- "--quiet"
|
|
585
593
|
- "--line-numbers"
|
|
@@ -601,8 +609,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
601
609
|
- !ruby/object:Gem::Version
|
|
602
610
|
version: '0'
|
|
603
611
|
requirements: []
|
|
604
|
-
rubygems_version: 3.3.
|
|
605
|
-
signing_key:
|
|
612
|
+
rubygems_version: 3.3.26
|
|
613
|
+
signing_key:
|
|
606
614
|
specification_version: 4
|
|
607
615
|
summary: The Database Toolkit for Ruby
|
|
608
616
|
test_files: []
|