sequel 5.63.0 → 5.64.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +10 -0
- data/doc/association_basics.rdoc +30 -0
- data/doc/release_notes/5.64.0.txt +50 -0
- data/lib/sequel/adapters/oracle.rb +1 -0
- data/lib/sequel/adapters/shared/access.rb +2 -2
- data/lib/sequel/adapters/shared/mysql.rb +1 -1
- data/lib/sequel/adapters/shared/oracle.rb +5 -5
- data/lib/sequel/adapters/shared/sqlanywhere.rb +1 -1
- data/lib/sequel/adapters/shared/sqlite.rb +3 -2
- data/lib/sequel/database/query.rb +38 -4
- data/lib/sequel/model/associations.rb +5 -0
- data/lib/sequel/plugins/many_through_many.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1971882f6efac487f21b4b5fb74695b757f2e129c14d82ffdca062cd5bc9d58f
|
4
|
+
data.tar.gz: ca4d9df4e18bd2806ad0a288856cb87f270f702a73f8de0ebea3934776d4304c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abdd0fbcb5da74256493a8cfb7ff32f9247d8b021096344d3d072d2d5981fec557ed222df11da3db12abae7318c43c09b9bb2c63795816244aea76425f4106ba
|
7
|
+
data.tar.gz: 7b37c7c8cdc9172baf273ee80b328fa79bd6694a070ef81220e31bbaa20bcb0dc90a137b5cccd4c0326a7b99f17dd57591deab375dbaf61881bac3536b4eeb12
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 5.64.0 (2023-01-01)
|
2
|
+
|
3
|
+
* Make :db_type column schema entries on SQLAnywhere include precision/scale information (jeremyevans)
|
4
|
+
|
5
|
+
* Include :min_value and :max_value schema entries for decimal/numeric columns on most databases (rolftimmermans, jeremyevans) (#1975)
|
6
|
+
|
7
|
+
* Support :graph_use_association_block association option to make eager_graph use the association block (jeremyevans)
|
8
|
+
|
9
|
+
* Make many_through_many and many_through_one associations support eager_graph callbacks (jeremyevans)
|
10
|
+
|
1
11
|
=== 5.63.0 (2022-12-01)
|
2
12
|
|
3
13
|
* Make validates_associated plugin avoid database type errors for non-integer association keys (jeremyevans) (#1968)
|
data/doc/association_basics.rdoc
CHANGED
@@ -1498,6 +1498,36 @@ as the qualifiers may not match the aliases automatically used by eager_graph.
|
|
1498
1498
|
This should contain unqualified identifiers, and eager_graph will automatically
|
1499
1499
|
qualify them with the appropriate alias.
|
1500
1500
|
|
1501
|
+
==== :graph_use_association_block
|
1502
|
+
|
1503
|
+
Setting this to true makes eager_graph apply the association block to the
|
1504
|
+
associated dataset before graphing the associated dataset into the receiver.
|
1505
|
+
In most cases when this option is used and the association has a block, the
|
1506
|
+
dataset returned by eager_graph will contain a JOIN to a subquery.
|
1507
|
+
|
1508
|
+
By default (when this option is not used), the association block will be ignored
|
1509
|
+
when using eager_graph:
|
1510
|
+
|
1511
|
+
Artist.one_to_many :tracks do |ds|
|
1512
|
+
ds.where(foo: 3)
|
1513
|
+
end
|
1514
|
+
Artist.eager_graph(:tracks)
|
1515
|
+
# SELECT albums.id, tracks.id AS tracks_id, tracks.album_id
|
1516
|
+
# FROM albums
|
1517
|
+
# LEFT OUTER JOIN tracks
|
1518
|
+
# ON (tracks.album_id = albums.id)
|
1519
|
+
|
1520
|
+
When this option is used, the block will be respected:
|
1521
|
+
|
1522
|
+
Artist.one_to_many :tracks, graph_use_association_block: true do |ds|
|
1523
|
+
ds.where(foo: 3)
|
1524
|
+
end
|
1525
|
+
Artist.eager_graph(:tracks)
|
1526
|
+
# SELECT albums.id, tracks.id AS tracks_id, tracks.album_id
|
1527
|
+
# FROM albums
|
1528
|
+
# LEFT OUTER JOIN (SELECT * FROM tracks WHERE (foo = 3)) AS tracks
|
1529
|
+
# ON (tracks.album_id = albums.id)
|
1530
|
+
|
1501
1531
|
==== :graph_join_table_conditions [+many_to_many+, +one_through_one+]
|
1502
1532
|
|
1503
1533
|
The additional conditions to use on the SQL join for the join table when
|
@@ -0,0 +1,50 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A :graph_use_association_block association option has been added,
|
4
|
+
which makes eager_graph use the association block (as eager does),
|
5
|
+
generally resulting in a JOIN to a subquery:
|
6
|
+
|
7
|
+
Artist.one_to_many :tracks, graph_use_association_block: true do |ds|
|
8
|
+
ds.where(foo: 3)
|
9
|
+
end
|
10
|
+
Artist.eager_graph(:tracks)
|
11
|
+
# SELECT albums.id, tracks.id AS tracks_id, tracks.album_id
|
12
|
+
# FROM albums
|
13
|
+
# LEFT OUTER JOIN (SELECT * FROM tracks WHERE (foo = 3)) AS tracks
|
14
|
+
# ON (tracks.album_id = albums.id)
|
15
|
+
|
16
|
+
Assuming that the database can optimize the query correctly, using
|
17
|
+
the :graph_use_association_block option is probably simpler than
|
18
|
+
than using other :graph_* options to duplicate the conditions added
|
19
|
+
by the association block.
|
20
|
+
|
21
|
+
* Numeric/Decimal column schema entries now include :min_value and
|
22
|
+
:max_value entries on most databases, indicating the minimum and
|
23
|
+
maximum values supported for the column. Similar to the support
|
24
|
+
for integer columns added in 5.62.0, this allows the
|
25
|
+
auto_validations plugin to automatically validate the values of
|
26
|
+
the columns are in the allowed range.
|
27
|
+
|
28
|
+
= Other Improvements
|
29
|
+
|
30
|
+
* many_through_{one,many} associations now support eager_graph
|
31
|
+
callbacks.
|
32
|
+
|
33
|
+
* The :db_type column schema entries on SQLAnywhere now include
|
34
|
+
precision/scale information, to work with the numeric/decimal
|
35
|
+
column min_value/max_value support.
|
36
|
+
|
37
|
+
* The oracle adapter now includes a :column_size column schema
|
38
|
+
entry containing the precision of the columns, to work with the
|
39
|
+
numeric/decimal column min_value/max_value support.
|
40
|
+
|
41
|
+
= Backwards Compatibility
|
42
|
+
|
43
|
+
* The private Database#column_schema_integer_min_max_values method
|
44
|
+
added in 5.62.0 now takes a column schema hash instead of a
|
45
|
+
database type string.
|
46
|
+
|
47
|
+
* Code that previously looked at the :db_type column schema entry on
|
48
|
+
SQLAnywhere should be updated to look at the :domain_name entry, and
|
49
|
+
code that looked at the :domain_name_with_size entry should be
|
50
|
+
updated to look at the :db_type entry.
|
@@ -312,6 +312,7 @@ module Sequel
|
|
312
312
|
:char_used => column.char_used?,
|
313
313
|
:char_size => column.char_size,
|
314
314
|
:data_size => column.data_size,
|
315
|
+
:column_size => column.precision,
|
315
316
|
:precision => column.precision,
|
316
317
|
:scale => column.scale,
|
317
318
|
:fsprecision => column.fsprecision,
|
@@ -60,8 +60,8 @@ module Sequel
|
|
60
60
|
# Access's Byte type will accept much larger values,
|
61
61
|
# even though it only stores 0-255. Do not set min/max
|
62
62
|
# values for the Byte type.
|
63
|
-
def column_schema_integer_min_max_values(
|
64
|
-
return if /byte/i =~ db_type
|
63
|
+
def column_schema_integer_min_max_values(column)
|
64
|
+
return if /byte/i =~ column[:db_type]
|
65
65
|
super
|
66
66
|
end
|
67
67
|
|
@@ -553,7 +553,7 @@ module Sequel
|
|
553
553
|
# Return nil if CHECK constraints are not supported, because
|
554
554
|
# versions that don't support check constraints don't raise
|
555
555
|
# errors for values outside of range.
|
556
|
-
def column_schema_integer_min_max_values(
|
556
|
+
def column_schema_integer_min_max_values(column)
|
557
557
|
super if supports_check_constraints?
|
558
558
|
end
|
559
559
|
|
@@ -178,11 +178,11 @@ module Sequel
|
|
178
178
|
''
|
179
179
|
end
|
180
180
|
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
def column_schema_integer_min_max_values(
|
185
|
-
|
181
|
+
# Support min/max integer values on Oracle only if
|
182
|
+
# they use a NUMBER column with a fixed precision
|
183
|
+
# and no scale.
|
184
|
+
def column_schema_integer_min_max_values(column)
|
185
|
+
super if column[:db_type] =~ /NUMBER\(\d+\)/i || (column[:db_type] == 'NUMBER' && column[:column_size].is_a?(Integer) && column[:scale] == 0)
|
186
186
|
end
|
187
187
|
|
188
188
|
def create_sequence_sql(name, opts=OPTS)
|
@@ -37,7 +37,7 @@ module Sequel
|
|
37
37
|
row[:auto_increment] = auto_increment == 1 || auto_increment == true
|
38
38
|
row[:primary_key] = row.delete(:pkey) == 'Y'
|
39
39
|
row[:allow_null] = row[:nulls_allowed].is_a?(Integer) ? row.delete(:nulls_allowed) == 1 : row.delete(:nulls_allowed)
|
40
|
-
row[:db_type] = row.delete(:
|
40
|
+
row[:db_type] = row.delete(:domain_name_with_size)
|
41
41
|
row[:type] = if row[:db_type] =~ /numeric/i and (row[:scale].is_a?(Integer) ? row[:scale] == 0 : !row[:scale])
|
42
42
|
:integer
|
43
43
|
else
|
@@ -320,10 +320,11 @@ module Sequel
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
|
323
|
-
# SQLite does not restrict the integer type to a specific range.
|
324
|
-
def column_schema_integer_min_max_values(
|
323
|
+
# SQLite does not restrict the integer or decimal type to a specific range.
|
324
|
+
def column_schema_integer_min_max_values(column)
|
325
325
|
nil
|
326
326
|
end
|
327
|
+
alias column_schema_decimal_min_max_values column_schema_integer_min_max_values
|
327
328
|
|
328
329
|
# Array of PRAGMA SQL statements based on the Database options that should be applied to
|
329
330
|
# new connections.
|
@@ -175,8 +175,14 @@ module Sequel
|
|
175
175
|
if !c[:max_length] && c[:type] == :string && (max_length = column_schema_max_length(c[:db_type]))
|
176
176
|
c[:max_length] = max_length
|
177
177
|
end
|
178
|
-
if !c[:max_value] && !c[:min_value]
|
179
|
-
|
178
|
+
if !c[:max_value] && !c[:min_value]
|
179
|
+
min_max = case c[:type]
|
180
|
+
when :integer
|
181
|
+
column_schema_integer_min_max_values(c)
|
182
|
+
when :decimal
|
183
|
+
column_schema_decimal_min_max_values(c)
|
184
|
+
end
|
185
|
+
c[:min_value], c[:max_value] = min_max if min_max
|
180
186
|
end
|
181
187
|
end
|
182
188
|
schema_post_process(cols)
|
@@ -288,7 +294,15 @@ module Sequel
|
|
288
294
|
|
289
295
|
# Look at the db_type and guess the minimum and maximum integer values for
|
290
296
|
# the column.
|
291
|
-
def column_schema_integer_min_max_values(
|
297
|
+
def column_schema_integer_min_max_values(column)
|
298
|
+
db_type = column[:db_type]
|
299
|
+
if /decimal|numeric|number/i =~ db_type
|
300
|
+
if min_max = column_schema_decimal_min_max_values(column)
|
301
|
+
min_max.map!(&:to_i)
|
302
|
+
end
|
303
|
+
return min_max
|
304
|
+
end
|
305
|
+
|
292
306
|
unsigned = /unsigned/i =~ db_type
|
293
307
|
case db_type
|
294
308
|
when /big|int8/i
|
@@ -304,6 +318,26 @@ module Sequel
|
|
304
318
|
end
|
305
319
|
end
|
306
320
|
|
321
|
+
# Look at the db_type and guess the minimum and maximum decimal values for
|
322
|
+
# the column.
|
323
|
+
def column_schema_decimal_min_max_values(column)
|
324
|
+
if column[:column_size] && column[:scale]
|
325
|
+
precision = column[:column_size]
|
326
|
+
scale = column[:scale]
|
327
|
+
elsif /\((\d+)(?:,\s*(-?\d+))?\)/ =~ column[:db_type]
|
328
|
+
precision = $1.to_i
|
329
|
+
scale = $2.to_i if $2
|
330
|
+
end
|
331
|
+
|
332
|
+
if precision
|
333
|
+
limit = BigDecimal("9" * precision)
|
334
|
+
if scale
|
335
|
+
limit /= 10**(scale)
|
336
|
+
end
|
337
|
+
[-limit, limit]
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
307
341
|
# Whether the tinyint type (if supported by the database) is unsigned by default.
|
308
342
|
def column_schema_tinyint_type_is_unsigned?
|
309
343
|
false
|
@@ -370,7 +404,7 @@ module Sequel
|
|
370
404
|
:boolean
|
371
405
|
when /\A(real|float( unsigned)?|double( precision)?|double\(\d+,\d+\)( unsigned)?)\z/io
|
372
406
|
:float
|
373
|
-
when /\A(?:(?:(?:num(?:ber|eric)?|decimal)(?:\(\d+,\s*(
|
407
|
+
when /\A(?:(?:(?:num(?:ber|eric)?|decimal)(?:\(\d+,\s*(-?\d+|false|true)\))?))\z/io
|
374
408
|
$1 && ['0', 'false'].include?($1) ? :integer : :decimal
|
375
409
|
when /bytea|blob|image|(var)?binary/io
|
376
410
|
:blob
|
@@ -1722,6 +1722,8 @@ module Sequel
|
|
1722
1722
|
# :graph_select :: A column or array of columns to select from the associated table
|
1723
1723
|
# when eagerly loading the association via +eager_graph+. Defaults to all
|
1724
1724
|
# columns in the associated table.
|
1725
|
+
# :graph_use_association_block :: Makes eager_graph consider the association block. Without this, eager_graph
|
1726
|
+
# ignores the bock and only use the :graph_* options.
|
1725
1727
|
# :instance_specific :: Marks the association as instance specific. Should be used if the association block
|
1726
1728
|
# uses instance specific state, or transient state (accessing current date/time, etc.).
|
1727
1729
|
# :limit :: Limit the number of records to the provided value. Use
|
@@ -2461,6 +2463,9 @@ module Sequel
|
|
2461
2463
|
# Return dataset to graph into given the association reflection, applying the :callback option if set.
|
2462
2464
|
def eager_graph_dataset(opts, eager_options)
|
2463
2465
|
ds = opts.associated_class.dataset
|
2466
|
+
if opts[:graph_use_association_block] && (b = opts[:block])
|
2467
|
+
ds = b.call(ds)
|
2468
|
+
end
|
2464
2469
|
if cb = eager_options[:callback]
|
2465
2470
|
ds = cb.call(ds)
|
2466
2471
|
end
|
@@ -385,7 +385,7 @@ module Sequel
|
|
385
385
|
iq = nil
|
386
386
|
end
|
387
387
|
fe = opts.final_edge
|
388
|
-
ds.graph(opts
|
388
|
+
ds.graph(eager_graph_dataset(opts, eo), use_only_conditions ? only_conditions : (Array(opts.right_primary_key).zip(Array(fe[:left])) + conditions), :select=>select, :table_alias=>eo[:table_alias], :qualify=>:deep, :join_type=>eo[:join_type]||join_type, :join_only=>eo[:join_only], &graph_block)
|
389
389
|
end
|
390
390
|
end
|
391
391
|
end
|
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 = 64
|
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.64.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:
|
11
|
+
date: 2023-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -195,6 +195,7 @@ extra_rdoc_files:
|
|
195
195
|
- doc/release_notes/5.61.0.txt
|
196
196
|
- doc/release_notes/5.62.0.txt
|
197
197
|
- doc/release_notes/5.63.0.txt
|
198
|
+
- doc/release_notes/5.64.0.txt
|
198
199
|
- doc/release_notes/5.7.0.txt
|
199
200
|
- doc/release_notes/5.8.0.txt
|
200
201
|
- doc/release_notes/5.9.0.txt
|
@@ -286,6 +287,7 @@ files:
|
|
286
287
|
- doc/release_notes/5.61.0.txt
|
287
288
|
- doc/release_notes/5.62.0.txt
|
288
289
|
- doc/release_notes/5.63.0.txt
|
290
|
+
- doc/release_notes/5.64.0.txt
|
289
291
|
- doc/release_notes/5.7.0.txt
|
290
292
|
- doc/release_notes/5.8.0.txt
|
291
293
|
- doc/release_notes/5.9.0.txt
|
@@ -609,7 +611,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
609
611
|
- !ruby/object:Gem::Version
|
610
612
|
version: '0'
|
611
613
|
requirements: []
|
612
|
-
rubygems_version: 3.
|
614
|
+
rubygems_version: 3.4.1
|
613
615
|
signing_key:
|
614
616
|
specification_version: 4
|
615
617
|
summary: The Database Toolkit for Ruby
|