sequel 5.56.0 → 5.57.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/doc/release_notes/5.57.0.txt +23 -0
- data/lib/sequel/adapters/shared/mysql.rb +6 -0
- data/lib/sequel/adapters/shared/postgres.rb +2 -0
- data/lib/sequel/database/schema_generator.rb +3 -0
- data/lib/sequel/extensions/is_distinct_from.rb +139 -0
- data/lib/sequel/plugins/insert_conflict.rb +4 -0
- data/lib/sequel/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab346b95d558c843b61291c10b7033a50fa3e68b1b6d76b16c36f35eea7669a
|
4
|
+
data.tar.gz: eb9acbdab39df252a1e1dd6e66c82a6b13a61544d04d709e46592310ada6f693
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 925cdbf7f82dcd9c98fadbaeba92e4b4f36a424e81bde6593a0dc9569d693dc16cc6cb901fe32d0839389348aa3870874589489db4ea4f70eb81e6b2d4e06de4
|
7
|
+
data.tar.gz: 270e046d9c90956dfb7e81d1e17c5baeba6feb563f8aaf66d86494697e5b59e027375b72e11b24d1eb23709b9e2272c2ed53430c4c4bfc1af2957bfba7e64416
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 5.57.0 (2022-06-01)
|
2
|
+
|
3
|
+
* Make Database#create_function on PostgreSQL accept :parallel option (bananarne) (#1870)
|
4
|
+
|
5
|
+
* Add support for :on_update_current_timestamp column option on MySQL (jeremyevans)
|
6
|
+
|
7
|
+
* Add is_distinct_from extension with support for the IS DISTINCT FROM operator (jeremyevans)
|
8
|
+
|
1
9
|
=== 5.56.0 (2022-05-01)
|
2
10
|
|
3
11
|
* Make alter_table add_column/add_foreign_key methods support :index option to create an index on the column (jeremyevans)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An is_distinct_from extension has been added with support for the
|
4
|
+
SQL IS DISTINCT FROM operator. This operator is similar to the
|
5
|
+
not equals operator, except in terms of NULL handling. It returns
|
6
|
+
true if only one side is NULL, and false if both sides are NULL.
|
7
|
+
You can call is_distinct_from on Sequel itself or on Sequel objects:
|
8
|
+
|
9
|
+
Sequel.is_distinct_from(:column_a, :column_b)
|
10
|
+
Sequel[:column_a].is_distinct_from(:column_b)
|
11
|
+
# (column_a IS DISTINCT FROM column_b)
|
12
|
+
|
13
|
+
On databases not supporting IS DISTINCT FROM, support is emulated
|
14
|
+
using a CASE statement.
|
15
|
+
|
16
|
+
* Column definitions on MySQL can use the :on_update_current_timestamp
|
17
|
+
option for ON UPDATE CURRENT_TIMESTAMP, which creates a column that
|
18
|
+
will automatically have its value set to CURRENT_TIMESTAMP on every
|
19
|
+
update.
|
20
|
+
|
21
|
+
* Database#create_function on PostgreSQL now supports a :parallel
|
22
|
+
option to set the thread safety of the funciton. The value should
|
23
|
+
be :safe, :unsafe, or :restricted.
|
@@ -356,6 +356,12 @@ module Sequel
|
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
+
# Support :on_update_current_timestamp option.
|
360
|
+
def column_definition_default_sql(sql, column)
|
361
|
+
super
|
362
|
+
sql << " ON UPDATE CURRENT_TIMESTAMP" if column[:on_update_current_timestamp]
|
363
|
+
end
|
364
|
+
|
359
365
|
# Add generation clause SQL fragment to column creation SQL.
|
360
366
|
def column_definition_generated_sql(sql, column)
|
361
367
|
if (generated_expression = column[:generated_always_as])
|
@@ -414,6 +414,7 @@ module Sequel
|
|
414
414
|
# 2 :: argument name
|
415
415
|
# 3 :: argument mode (e.g. in, out, inout)
|
416
416
|
# :behavior :: Should be IMMUTABLE, STABLE, or VOLATILE. PostgreSQL assumes VOLATILE by default.
|
417
|
+
# :parallel :: The thread safety attribute of the function. Should be SAFE, UNSAFE, RESTRICTED. PostgreSQL assumes UNSAFE by default.
|
417
418
|
# :cost :: The estimated cost of the function, used by the query planner.
|
418
419
|
# :language :: The language the function uses. SQL is the default.
|
419
420
|
# :link_symbol :: For a dynamically loaded see function, the function's link symbol if different from the definition argument.
|
@@ -1117,6 +1118,7 @@ module Sequel
|
|
1117
1118
|
#{opts[:behavior].to_s.upcase if opts[:behavior]}
|
1118
1119
|
#{'STRICT' if opts[:strict]}
|
1119
1120
|
#{'SECURITY DEFINER' if opts[:security_definer]}
|
1121
|
+
#{"PARALLEL #{opts[:parallel].to_s.upcase}" if opts[:parallel]}
|
1120
1122
|
#{"COST #{opts[:cost]}" if opts[:cost]}
|
1121
1123
|
#{"ROWS #{opts[:rows]}" if opts[:rows]}
|
1122
1124
|
#{opts[:set].map{|k,v| " SET #{k} = #{v}"}.join("\n") if opts[:set]}
|
@@ -146,6 +146,9 @@ module Sequel
|
|
146
146
|
#
|
147
147
|
# :generated_type :: Set the type of column when using :generated_always_as,
|
148
148
|
# should be :virtual or :stored to force a type.
|
149
|
+
# :on_update_current_timestamp :: Use ON UPDATE CURRENT TIMESTAMP when defining the column,
|
150
|
+
# which will update the column value to CURRENT_TIMESTAMP
|
151
|
+
# on every UPDATE.
|
149
152
|
#
|
150
153
|
# Microsoft SQL Server specific options:
|
151
154
|
#
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
3
|
+
# The is_distinct_from extension adds the ability to use the
|
4
|
+
# SQL standard IS DISTINCT FROM operator, which is similar to the
|
5
|
+
# not equals operator, except that NULL values are considered
|
6
|
+
# equal. Only PostgreSQL and H2 currently support this operator. On
|
7
|
+
# other databases, support is emulated.
|
8
|
+
#
|
9
|
+
# First, you need to load the extension into the database:
|
10
|
+
#
|
11
|
+
# DB.extension :is_distinct_from
|
12
|
+
#
|
13
|
+
# Then you can use the Sequel.is_distinct_from to create the expression
|
14
|
+
# objects:
|
15
|
+
#
|
16
|
+
# expr = Sequel.is_distinct_from(:column_a, :column_b)
|
17
|
+
# # (column_a IS DISTINCT FROM column_b)
|
18
|
+
#
|
19
|
+
# You can also use the +is_distinct_from+ method on most Sequel expressions:
|
20
|
+
#
|
21
|
+
# expr = Sequel[:column_a].is_distinct_from(:column_b)
|
22
|
+
# # (column_a IS DISTINCT FROM column_b)
|
23
|
+
#
|
24
|
+
# These expressions can be used in your datasets, or anywhere else that
|
25
|
+
# Sequel expressions are allowed:
|
26
|
+
#
|
27
|
+
# DB[:table].where(expr)
|
28
|
+
#
|
29
|
+
# Related module: Sequel::SQL::IsDistinctFrom
|
30
|
+
|
31
|
+
#
|
32
|
+
module Sequel
|
33
|
+
module SQL
|
34
|
+
module Builders
|
35
|
+
# Return a IsDistinctFrom expression object, using the IS DISTINCT FROM operator
|
36
|
+
# with the given left hand side and right hand side.
|
37
|
+
def is_distinct_from(lhs, rhs)
|
38
|
+
BooleanExpression.new(:NOOP, IsDistinctFrom.new(lhs, rhs))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Represents an SQL expression using the IS DISTINCT FROM operator.
|
43
|
+
class IsDistinctFrom < GenericExpression
|
44
|
+
# These methods are added to expressions, allowing them to return IS DISTINCT
|
45
|
+
# FROM expressions based on the receiving expression.
|
46
|
+
module Methods
|
47
|
+
# Return a IsDistinctFrom expression, using the IS DISTINCT FROM operator,
|
48
|
+
# with the receiver as the left hand side and the argument as the right hand side.
|
49
|
+
def is_distinct_from(rhs)
|
50
|
+
BooleanExpression.new(:NOOP, IsDistinctFrom.new(self, rhs))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# These methods are added to datasets using the is_distinct_from extension
|
55
|
+
# extension, for the purposes of correctly literalizing IsDistinctFrom
|
56
|
+
# expressions for the appropriate database type.
|
57
|
+
module DatasetMethods
|
58
|
+
# Append the SQL fragment for the IS DISTINCT FROM expression to the SQL query.
|
59
|
+
def is_distinct_from_sql_append(sql, idf)
|
60
|
+
lhs = idf.lhs
|
61
|
+
rhs = idf.rhs
|
62
|
+
|
63
|
+
if supports_is_distinct_from?
|
64
|
+
sql << "("
|
65
|
+
literal_append(sql, lhs)
|
66
|
+
sql << " IS DISTINCT FROM "
|
67
|
+
literal_append(sql, rhs)
|
68
|
+
sql << ")"
|
69
|
+
elsif db.database_type == :derby && (lhs == nil || rhs == nil)
|
70
|
+
if lhs == nil && rhs == nil
|
71
|
+
sql << literal_false
|
72
|
+
elsif lhs == nil
|
73
|
+
literal_append(sql, ~Sequel.expr(rhs=>nil))
|
74
|
+
else
|
75
|
+
literal_append(sql, ~Sequel.expr(lhs=>nil))
|
76
|
+
end
|
77
|
+
else
|
78
|
+
literal_append(sql, Sequel.case({(Sequel.expr(lhs=>rhs) | [[lhs, nil], [rhs, nil]]) => 0}, 1) => 1)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
# Whether the database supports IS DISTINCT FROM.
|
85
|
+
def supports_is_distinct_from?
|
86
|
+
if defined?(super)
|
87
|
+
return super
|
88
|
+
end
|
89
|
+
|
90
|
+
case db.database_type
|
91
|
+
when :postgres, :h2
|
92
|
+
true
|
93
|
+
else
|
94
|
+
false
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# The left hand side of the IS DISTINCT FROM expression.
|
100
|
+
attr_reader :lhs
|
101
|
+
|
102
|
+
# The right hand side of the IS DISTINCT FROM expression.
|
103
|
+
attr_reader :rhs
|
104
|
+
|
105
|
+
def initialize(lhs, rhs)
|
106
|
+
@lhs = lhs
|
107
|
+
@rhs = rhs
|
108
|
+
end
|
109
|
+
|
110
|
+
to_s_method :is_distinct_from_sql
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class SQL::GenericExpression
|
115
|
+
include SQL::IsDistinctFrom::Methods
|
116
|
+
end
|
117
|
+
|
118
|
+
class LiteralString
|
119
|
+
include SQL::IsDistinctFrom::Methods
|
120
|
+
end
|
121
|
+
|
122
|
+
Dataset.register_extension(:is_distinct_from, SQL::IsDistinctFrom::DatasetMethods)
|
123
|
+
end
|
124
|
+
|
125
|
+
# :nocov:
|
126
|
+
if Sequel.core_extensions?
|
127
|
+
class Symbol
|
128
|
+
include Sequel::SQL::IsDistinctFrom::Methods
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
if defined?(Sequel::CoreRefinements)
|
133
|
+
module Sequel::CoreRefinements
|
134
|
+
refine Symbol do
|
135
|
+
send INCLUDE_METH, Sequel::SQL::IsDistinctFrom::Methods
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
# :nocov:
|
@@ -22,6 +22,10 @@ module Sequel
|
|
22
22
|
# for that album. See the PostgreSQL and SQLite adapter documention for
|
23
23
|
# the options you can pass to the insert_conflict method.
|
24
24
|
#
|
25
|
+
# You should not attempt to use this plugin to ignore conflicts when
|
26
|
+
# inserting, you should only use it to turn insert conflicts into updates.
|
27
|
+
# Any usage to ignore conflicts is not recommended or supported.
|
28
|
+
#
|
25
29
|
# Usage:
|
26
30
|
#
|
27
31
|
# # Make all model subclasses support insert_conflict
|
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 = 57
|
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.57.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: 2022-
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -201,6 +201,7 @@ extra_rdoc_files:
|
|
201
201
|
- doc/release_notes/5.54.0.txt
|
202
202
|
- doc/release_notes/5.55.0.txt
|
203
203
|
- doc/release_notes/5.56.0.txt
|
204
|
+
- doc/release_notes/5.57.0.txt
|
204
205
|
- doc/release_notes/5.6.0.txt
|
205
206
|
- doc/release_notes/5.7.0.txt
|
206
207
|
- doc/release_notes/5.8.0.txt
|
@@ -285,6 +286,7 @@ files:
|
|
285
286
|
- doc/release_notes/5.54.0.txt
|
286
287
|
- doc/release_notes/5.55.0.txt
|
287
288
|
- doc/release_notes/5.56.0.txt
|
289
|
+
- doc/release_notes/5.57.0.txt
|
288
290
|
- doc/release_notes/5.6.0.txt
|
289
291
|
- doc/release_notes/5.7.0.txt
|
290
292
|
- doc/release_notes/5.8.0.txt
|
@@ -414,6 +416,7 @@ files:
|
|
414
416
|
- lib/sequel/extensions/index_caching.rb
|
415
417
|
- lib/sequel/extensions/inflector.rb
|
416
418
|
- lib/sequel/extensions/integer64.rb
|
419
|
+
- lib/sequel/extensions/is_distinct_from.rb
|
417
420
|
- lib/sequel/extensions/looser_typecasting.rb
|
418
421
|
- lib/sequel/extensions/migration.rb
|
419
422
|
- lib/sequel/extensions/mssql_emulate_lateral_with_apply.rb
|