sequel 5.65.0 → 5.66.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 +10 -0
- data/doc/release_notes/5.66.0.txt +24 -0
- data/lib/sequel/adapters/shared/mssql.rb +25 -0
- data/lib/sequel/adapters/shared/oracle.rb +6 -1
- data/lib/sequel/adapters/shared/postgres.rb +12 -0
- data/lib/sequel/adapters/shared/sqlite.rb +13 -0
- data/lib/sequel/dataset/actions.rb +1 -1
- data/lib/sequel/dataset/sql.rb +6 -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: 7284ac53d44e98a2ddaf7c0e8068fe0716a9071bef14c484bbe77cc553d775f0
|
4
|
+
data.tar.gz: '0828c8d85355205f8b6ee8a58ba5f9b85ebec07381a687f08fa909e883ac8eed'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e42c07446ea4cd3b42eb566a20cf81b4fb7e641d7b521ead6bcfc32a8ff0a0bf7b76d7a2a8ba654a0bdd80a67db6def93ba1efba61dd5eeebf68a14cdb722a
|
7
|
+
data.tar.gz: ad7397637ab9bfb0903eff1c46c8ed5901bc2eff3a4ba5a2411ba61fb32f9e6d00871063cc55f6d21798f5790f0a5158c19f0343839a6d6750b53a3301395c90
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 5.66.0 (2023-03-01)
|
2
|
+
|
3
|
+
* Recognize SQLite error related to strict tables as a constraint violation when using the amalgalite adapter (jeremyevans)
|
4
|
+
|
5
|
+
* Make Dataset#count work correctly for datasets using Dataset#values (jeremyevans) (#1992)
|
6
|
+
|
7
|
+
* Make Dataset#count with no argument/block handle dataset with custom SQL using ORDER BY on MSSQL (jeremyevans)
|
8
|
+
|
9
|
+
* Make Dataset#empty? correctly handle datasets with custom SQL or using Dataset#values where the first value is NULL (andy-k, jeremyevans) (#1990)
|
10
|
+
|
1
11
|
=== 5.65.0 (2023-02-01)
|
2
12
|
|
3
13
|
* Allow pg_auto_parameterize extension to use placeholder loaders (jeremyevans)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
= Improvements
|
2
|
+
|
3
|
+
* Dataset#empty? now correctly handles datasets using custom SQL or
|
4
|
+
Dataset#values where the first value in the first row is NULL.
|
5
|
+
|
6
|
+
* Dataset#count without an argument or block now works correctly on
|
7
|
+
Microsoft SQL Server when using custom SQL that uses ORDER BY.
|
8
|
+
|
9
|
+
* Dataset#count now works correctly for datasets using Dataset#values.
|
10
|
+
|
11
|
+
* Sequel now recognizes an additional SQLite constraint violation
|
12
|
+
error that occurs with recent versions of amalgalite.
|
13
|
+
|
14
|
+
* Dataset#values will now raise an exception when called with an empty
|
15
|
+
array. Previously, an exception would not be raised until the query
|
16
|
+
was sent to the database.
|
17
|
+
|
18
|
+
= Backwards Compatibility
|
19
|
+
|
20
|
+
* The changes to make Dataset#empty? and #count work with custom SQL
|
21
|
+
on Microsoft SQL Server now result in running the custom SQL, which
|
22
|
+
could result in worse performance than in previous versions. You can
|
23
|
+
wrap such datasets with Dataset#from_self manually to restore the
|
24
|
+
previous behavior.
|
@@ -591,6 +591,18 @@ module Sequel
|
|
591
591
|
end
|
592
592
|
end
|
593
593
|
|
594
|
+
# For a dataset with custom SQL, since it may include ORDER BY, you
|
595
|
+
# cannot wrap it in a subquery. Load entire query in this case to get
|
596
|
+
# the number of rows. In general, you should avoid calling this method
|
597
|
+
# on datasets with custom SQL.
|
598
|
+
def count(*a, &block)
|
599
|
+
if (@opts[:sql] && a.empty? && !block)
|
600
|
+
naked.to_a.length
|
601
|
+
else
|
602
|
+
super
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
594
606
|
# Uses CROSS APPLY to join the given table into the current dataset.
|
595
607
|
def cross_apply(table)
|
596
608
|
join_table(:cross_apply, table)
|
@@ -601,6 +613,19 @@ module Sequel
|
|
601
613
|
clone(:disable_insert_output=>true)
|
602
614
|
end
|
603
615
|
|
616
|
+
# For a dataset with custom SQL, since it may include ORDER BY, you
|
617
|
+
# cannot wrap it in a subquery. Run query, and if it returns any
|
618
|
+
# records, return true. In general, you should avoid calling this method
|
619
|
+
# on datasets with custom SQL.
|
620
|
+
def empty?
|
621
|
+
if @opts[:sql]
|
622
|
+
naked.each{return false}
|
623
|
+
true
|
624
|
+
else
|
625
|
+
super
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
604
629
|
# MSSQL treats [] as a metacharacter in LIKE expresions.
|
605
630
|
def escape_like(string)
|
606
631
|
string.gsub(/[\\%_\[\]]/){|m| "\\#{m}"}
|
@@ -385,7 +385,12 @@ module Sequel
|
|
385
385
|
# Use a custom expression with EXISTS to determine whether a dataset
|
386
386
|
# is empty.
|
387
387
|
def empty?
|
388
|
-
|
388
|
+
if @opts[:sql]
|
389
|
+
naked.each{return false}
|
390
|
+
true
|
391
|
+
else
|
392
|
+
db[:dual].where(@opts[:offset] ? exists : unordered.exists).get(1) == nil
|
393
|
+
end
|
389
394
|
end
|
390
395
|
|
391
396
|
# Oracle requires SQL standard datetimes
|
@@ -805,6 +805,7 @@ module Sequel
|
|
805
805
|
# DB.values([[1, 2], [3, 4]]).order(:column2).limit(1, 1)
|
806
806
|
# # VALUES ((1, 2), (3, 4)) ORDER BY column2 LIMIT 1 OFFSET 1
|
807
807
|
def values(v)
|
808
|
+
raise Error, "Cannot provide an empty array for values" if v.empty?
|
808
809
|
@default_dataset.clone(:values=>v)
|
809
810
|
end
|
810
811
|
|
@@ -1706,6 +1707,12 @@ module Sequel
|
|
1706
1707
|
clone(:disable_insert_returning=>true)
|
1707
1708
|
end
|
1708
1709
|
|
1710
|
+
# Always return false when using VALUES
|
1711
|
+
def empty?
|
1712
|
+
return false if @opts[:values]
|
1713
|
+
super
|
1714
|
+
end
|
1715
|
+
|
1709
1716
|
# Return the results of an EXPLAIN query as a string
|
1710
1717
|
def explain(opts=OPTS)
|
1711
1718
|
with_sql((opts[:analyze] ? 'EXPLAIN ANALYZE ' : 'EXPLAIN ') + select_sql).map(:'QUERY PLAN').join("\r\n")
|
@@ -2125,6 +2132,11 @@ module Sequel
|
|
2125
2132
|
"TRUNCATE TABLE#{' ONLY' if to[:only]} #{table}#{' RESTART IDENTITY' if to[:restart]}#{' CASCADE' if to[:cascade]}"
|
2126
2133
|
end
|
2127
2134
|
|
2135
|
+
# Use from_self for aggregate dataset using VALUES.
|
2136
|
+
def aggreate_dataset_use_from_self?
|
2137
|
+
super || @opts[:values]
|
2138
|
+
end
|
2139
|
+
|
2128
2140
|
# Allow truncation of multiple source tables.
|
2129
2141
|
def check_truncation_allowed!
|
2130
2142
|
raise(InvalidOperation, "Grouped datasets cannot be truncated") if opts[:group]
|
@@ -169,6 +169,7 @@ module Sequel
|
|
169
169
|
# DB.values([[1, 2], [3, 4]])
|
170
170
|
# # VALUES ((1, 2), (3, 4))
|
171
171
|
def values(v)
|
172
|
+
raise Error, "Cannot provide an empty array for values" if v.empty?
|
172
173
|
@default_dataset.clone(:values=>v)
|
173
174
|
end
|
174
175
|
|
@@ -356,6 +357,7 @@ module Sequel
|
|
356
357
|
DATABASE_ERROR_REGEXPS = {
|
357
358
|
/(is|are) not unique\z|PRIMARY KEY must be unique\z|UNIQUE constraint failed: .+\z/ => UniqueConstraintViolation,
|
358
359
|
/foreign key constraint failed\z/i => ForeignKeyConstraintViolation,
|
360
|
+
/\ASQLITE ERROR 3091/ => CheckConstraintViolation,
|
359
361
|
/\A(SQLITE ERROR 275 \(CONSTRAINT_CHECK\) : )?CHECK constraint failed/ => CheckConstraintViolation,
|
360
362
|
/\A(SQLITE ERROR 19 \(CONSTRAINT\) : )?constraint failed\z/ => ConstraintViolation,
|
361
363
|
/\Acannot store [A-Z]+ value in [A-Z]+ column / => ConstraintViolation,
|
@@ -655,6 +657,12 @@ module Sequel
|
|
655
657
|
@opts[:where] ? super : where(1=>1).delete(&block)
|
656
658
|
end
|
657
659
|
|
660
|
+
# Always return false when using VALUES
|
661
|
+
def empty?
|
662
|
+
return false if @opts[:values]
|
663
|
+
super
|
664
|
+
end
|
665
|
+
|
658
666
|
# Return an array of strings specifying a query explanation for a SELECT of the
|
659
667
|
# current dataset. Currently, the options are ignored, but it accepts options
|
660
668
|
# to be compatible with other adapters.
|
@@ -868,6 +876,11 @@ module Sequel
|
|
868
876
|
end
|
869
877
|
end
|
870
878
|
|
879
|
+
# Use from_self for aggregate dataset using VALUES.
|
880
|
+
def aggreate_dataset_use_from_self?
|
881
|
+
super || @opts[:values]
|
882
|
+
end
|
883
|
+
|
871
884
|
# SQLite uses string literals instead of identifiers in AS clauses.
|
872
885
|
def as_sql_append(sql, aliaz, column_aliases=nil)
|
873
886
|
raise Error, "sqlite does not support derived column lists" if column_aliases
|
@@ -174,7 +174,7 @@ module Sequel
|
|
174
174
|
# # => false
|
175
175
|
def empty?
|
176
176
|
cached_dataset(:_empty_ds) do
|
177
|
-
single_value_ds.unordered.select(EMPTY_SELECT)
|
177
|
+
(@opts[:sql] ? from_self : self).single_value_ds.unordered.select(EMPTY_SELECT)
|
178
178
|
end.single_value!.nil?
|
179
179
|
end
|
180
180
|
|
data/lib/sequel/dataset/sql.rb
CHANGED
@@ -977,7 +977,12 @@ module Sequel
|
|
977
977
|
# order if not. Also removes the row_proc, which isn't needed
|
978
978
|
# for aggregate calculations.
|
979
979
|
def aggregate_dataset
|
980
|
-
(
|
980
|
+
(aggreate_dataset_use_from_self? ? from_self : unordered).naked
|
981
|
+
end
|
982
|
+
|
983
|
+
# Whether to use from_self for an aggregate dataset.
|
984
|
+
def aggreate_dataset_use_from_self?
|
985
|
+
options_overlap(COUNT_FROM_SELF_OPTS)
|
981
986
|
end
|
982
987
|
|
983
988
|
# Append aliasing expression to SQL string.
|
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 = 66
|
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.66.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: 2023-
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -197,6 +197,7 @@ extra_rdoc_files:
|
|
197
197
|
- doc/release_notes/5.63.0.txt
|
198
198
|
- doc/release_notes/5.64.0.txt
|
199
199
|
- doc/release_notes/5.65.0.txt
|
200
|
+
- doc/release_notes/5.66.0.txt
|
200
201
|
- doc/release_notes/5.7.0.txt
|
201
202
|
- doc/release_notes/5.8.0.txt
|
202
203
|
- doc/release_notes/5.9.0.txt
|
@@ -290,6 +291,7 @@ files:
|
|
290
291
|
- doc/release_notes/5.63.0.txt
|
291
292
|
- doc/release_notes/5.64.0.txt
|
292
293
|
- doc/release_notes/5.65.0.txt
|
294
|
+
- doc/release_notes/5.66.0.txt
|
293
295
|
- doc/release_notes/5.7.0.txt
|
294
296
|
- doc/release_notes/5.8.0.txt
|
295
297
|
- doc/release_notes/5.9.0.txt
|
@@ -613,7 +615,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
613
615
|
- !ruby/object:Gem::Version
|
614
616
|
version: '0'
|
615
617
|
requirements: []
|
616
|
-
rubygems_version: 3.4.
|
618
|
+
rubygems_version: 3.4.6
|
617
619
|
signing_key:
|
618
620
|
specification_version: 4
|
619
621
|
summary: The Database Toolkit for Ruby
|