sequel 5.39.0 → 5.40.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.40.0.txt +40 -0
- data/lib/sequel/adapters/jdbc.rb +2 -2
- data/lib/sequel/adapters/shared/sqlite.rb +35 -1
- data/lib/sequel/dataset/features.rb +10 -0
- data/lib/sequel/dataset/prepared_statements.rb +2 -0
- data/lib/sequel/dataset/sql.rb +32 -10
- data/lib/sequel/extensions/blank.rb +6 -0
- data/lib/sequel/extensions/date_arithmetic.rb +6 -3
- data/lib/sequel/extensions/eval_inspect.rb +2 -0
- data/lib/sequel/extensions/inflector.rb +6 -0
- data/lib/sequel/extensions/migration.rb +2 -0
- data/lib/sequel/extensions/pg_array.rb +1 -0
- data/lib/sequel/extensions/pg_interval.rb +22 -6
- data/lib/sequel/extensions/pg_row.rb +1 -0
- data/lib/sequel/extensions/query.rb +2 -0
- data/lib/sequel/model/associations.rb +1 -0
- data/lib/sequel/model/base.rb +21 -4
- data/lib/sequel/model/plugins.rb +5 -0
- data/lib/sequel/plugins/association_proxies.rb +2 -0
- data/lib/sequel/plugins/composition.rb +5 -1
- data/lib/sequel/plugins/constraint_validations.rb +2 -1
- data/lib/sequel/plugins/dataset_associations.rb +4 -1
- data/lib/sequel/plugins/nested_attributes.rb +3 -1
- data/lib/sequel/plugins/pg_array_associations.rb +4 -0
- data/lib/sequel/plugins/pg_auto_constraint_validations.rb +2 -0
- data/lib/sequel/version.rb +1 -1
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3391bf9fe9e592892ad8ba6b39f7016fe94524908243e7c85fdf5b1cbf9a62a
|
4
|
+
data.tar.gz: 3b3c946fefa8c16b8f657c191debf49f8db84cb9cadb5a91ecdb01739c2ec1e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e7812b8851cdcc9e374bcd8439cc4e3dbbedfd550c72b54aa9d6aa16e3bad1e5f59eed824bdef026d784b67450d2f861be8776ddb762be58406cca75f7a0ea9
|
7
|
+
data.tar.gz: a60bcc72355a1916a0639c5a99ec806f157d60b515112ec24c1757f9a43efc587593a0b11a1e5312d3f40431b313f8f6fc241eee7e7a37c5362565db7c4c8d3c
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 5.40.0 (2021-01-01)
|
2
|
+
|
3
|
+
* Support UPDATE FROM syntax in SQLite 3.33.0+ (jeremyevans)
|
4
|
+
|
5
|
+
* Have pg_interval extension work with ActiveSupport 6.1 (jeremyevans)
|
6
|
+
|
7
|
+
* Have date_arithmetic extension work with ActiveSupport 6.1 (jeremyevans)
|
8
|
+
|
9
|
+
* Avoid method redefinition warnings in verbose warning mode (jeremyevans)
|
10
|
+
|
1
11
|
=== 5.39.0 (2020-12-01)
|
2
12
|
|
3
13
|
* Support :clustered option for primary key and unique constraints on Microsoft SQL Server (jeremyevans)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* On SQLite 3.33.0+, the UPDATE FROM syntax is now supported. This
|
4
|
+
allows you to update one table based on a join to another table.
|
5
|
+
The SQLite syntax is based on the PostgreSQL syntax, and the
|
6
|
+
Sequel API is the same for both. You need to pass multiple tables
|
7
|
+
to Dataset#from. The first table is the table to update, and the
|
8
|
+
remaining tables are used to construct the UPDATE FROM clause:
|
9
|
+
|
10
|
+
DB[:a, :b].where{{a[:c]=>b[:d]}}.update(:e=>'f')
|
11
|
+
# UPDATE a SET e = 'f' FROM b WHERE (a.c = b.d)
|
12
|
+
|
13
|
+
Unlike PostgreSQL, SQLite does not support the deletion of joined
|
14
|
+
datasets. Related to this, the following methods for testing
|
15
|
+
database support for modifying joined datasets have been added:
|
16
|
+
|
17
|
+
* supports_updating_joins?
|
18
|
+
* supports_deleting_joins?
|
19
|
+
|
20
|
+
= Other Improvements
|
21
|
+
|
22
|
+
* The pg_interval and date_arithmetic extensions now support
|
23
|
+
ActiveSupport 6.1.
|
24
|
+
|
25
|
+
* Sequel no longer issues method redefinition warnings in verbose
|
26
|
+
mode. As Ruby 3 has dropped uninitialized instance variable
|
27
|
+
warnings, Sequel is now verbose warning free on Ruby 3.
|
28
|
+
|
29
|
+
= Backwards Compatibility
|
30
|
+
|
31
|
+
* Trying to truncate or insert into a joined dataset now correctly
|
32
|
+
raises an exception even if the joined dataset supports updates.
|
33
|
+
|
34
|
+
* The private Dataset#check_modification_allowed! method is now
|
35
|
+
deprecated, and users (custom adapters) should now switch to one
|
36
|
+
of the more specific methods introduced in this version:
|
37
|
+
|
38
|
+
* check_insert_allowed!
|
39
|
+
* check_update_allowed!
|
40
|
+
* check_delete_allowed!
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -71,11 +71,11 @@ module Sequel
|
|
71
71
|
class TypeConvertor
|
72
72
|
CONVERTORS = convertors = {}
|
73
73
|
%w'Boolean Float Double Int Long Short'.each do |meth|
|
74
|
-
x = convertors[meth.to_sym] = Object.new
|
74
|
+
x = x = convertors[meth.to_sym] = Object.new
|
75
75
|
class_eval("def x.call(r, i) v = r.get#{meth}(i); v unless r.wasNull end", __FILE__, __LINE__)
|
76
76
|
end
|
77
77
|
%w'Object Array String Time Date Timestamp BigDecimal Blob Bytes Clob'.each do |meth|
|
78
|
-
x = convertors[meth.to_sym] = Object.new
|
78
|
+
x = x = convertors[meth.to_sym] = Object.new
|
79
79
|
class_eval("def x.call(r, i) r.get#{meth}(i) end", __FILE__, __LINE__)
|
80
80
|
end
|
81
81
|
x = convertors[:RubyTime] = Object.new
|
@@ -561,7 +561,7 @@ module Sequel
|
|
561
561
|
Dataset.def_sql_method(self, :delete, [['if db.sqlite_version >= 30803', %w'with delete from where'], ["else", %w'delete from where']])
|
562
562
|
Dataset.def_sql_method(self, :insert, [['if db.sqlite_version >= 30803', %w'with insert conflict into columns values on_conflict'], ["else", %w'insert conflict into columns values']])
|
563
563
|
Dataset.def_sql_method(self, :select, [['if opts[:values]', %w'with values compounds'], ['else', %w'with select distinct columns from join where group having window compounds order limit lock']])
|
564
|
-
Dataset.def_sql_method(self, :update, [['if db.sqlite_version >= 30803', %w'with update table set where'], ["else", %w'update table set where']])
|
564
|
+
Dataset.def_sql_method(self, :update, [['if db.sqlite_version >= 33300', %w'with update table set from where'], ['elsif db.sqlite_version >= 30803', %w'with update table set where'], ["else", %w'update table set where']])
|
565
565
|
|
566
566
|
def cast_sql_append(sql, expr, type)
|
567
567
|
if type == Time or type == DateTime
|
@@ -753,6 +753,11 @@ module Sequel
|
|
753
753
|
false
|
754
754
|
end
|
755
755
|
|
756
|
+
# SQLite does not support deleting from a joined dataset
|
757
|
+
def supports_deleting_joins?
|
758
|
+
false
|
759
|
+
end
|
760
|
+
|
756
761
|
# SQLite does not support INTERSECT ALL or EXCEPT ALL
|
757
762
|
def supports_intersect_except_all?
|
758
763
|
false
|
@@ -763,6 +768,11 @@ module Sequel
|
|
763
768
|
false
|
764
769
|
end
|
765
770
|
|
771
|
+
# SQLite 3.33.0 supports modifying joined datasets
|
772
|
+
def supports_modifying_joins?
|
773
|
+
db.sqlite_version >= 33300
|
774
|
+
end
|
775
|
+
|
766
776
|
# SQLite does not support multiple columns for the IN/NOT IN operators
|
767
777
|
def supports_multiple_column_in?
|
768
778
|
false
|
@@ -825,6 +835,13 @@ module Sequel
|
|
825
835
|
end
|
826
836
|
end
|
827
837
|
|
838
|
+
# Raise an InvalidOperation exception if insert is not allowed for this dataset.
|
839
|
+
def check_insert_allowed!
|
840
|
+
raise(InvalidOperation, "Grouped datasets cannot be modified") if opts[:group]
|
841
|
+
raise(InvalidOperation, "Joined datasets cannot be modified") if joined_dataset?
|
842
|
+
end
|
843
|
+
alias check_delete_allowed! check_insert_allowed!
|
844
|
+
|
828
845
|
# SQLite supports a maximum of 500 rows in a VALUES clause.
|
829
846
|
def default_import_slice
|
830
847
|
500
|
@@ -944,6 +961,23 @@ module Sequel
|
|
944
961
|
def _truncate_sql(table)
|
945
962
|
"DELETE FROM #{table}"
|
946
963
|
end
|
964
|
+
|
965
|
+
# Use FROM to specify additional tables in an update query
|
966
|
+
def update_from_sql(sql)
|
967
|
+
if(from = @opts[:from][1..-1]).empty?
|
968
|
+
raise(Error, 'Need multiple FROM tables if updating/deleting a dataset with JOINs') if @opts[:join]
|
969
|
+
else
|
970
|
+
sql << ' FROM '
|
971
|
+
source_list_append(sql, from)
|
972
|
+
select_join_sql(sql)
|
973
|
+
end
|
974
|
+
end
|
975
|
+
|
976
|
+
# Only include the primary table in the main update clause
|
977
|
+
def update_table_sql(sql)
|
978
|
+
sql << ' '
|
979
|
+
source_list_append(sql, @opts[:from][0..0])
|
980
|
+
end
|
947
981
|
end
|
948
982
|
end
|
949
983
|
end
|
@@ -51,6 +51,11 @@ module Sequel
|
|
51
51
|
false
|
52
52
|
end
|
53
53
|
|
54
|
+
# Whether deleting from joined datasets is supported, false by default.
|
55
|
+
def supports_deleting_joins?
|
56
|
+
supports_modifying_joins?
|
57
|
+
end
|
58
|
+
|
54
59
|
# Whether the database supports derived column lists (e.g.
|
55
60
|
# "table_expr AS table_alias(column_alias1, column_alias2, ...)"), true by
|
56
61
|
# default.
|
@@ -178,6 +183,11 @@ module Sequel
|
|
178
183
|
true
|
179
184
|
end
|
180
185
|
|
186
|
+
# Whether updating joined datasets is supported, false by default.
|
187
|
+
def supports_updating_joins?
|
188
|
+
supports_modifying_joins?
|
189
|
+
end
|
190
|
+
|
181
191
|
# Whether the dataset supports the WINDOW clause to define windows used by multiple
|
182
192
|
# window functions, false by default.
|
183
193
|
def supports_window_clause?
|
@@ -201,7 +201,9 @@ module Sequel
|
|
201
201
|
when :insert_pk
|
202
202
|
fetch_rows(prepared_sql){|r| return r.values.first}
|
203
203
|
when Array
|
204
|
+
# :nocov:
|
204
205
|
case prepared_type[0]
|
206
|
+
# :nocov:
|
205
207
|
when :map, :as_hash, :to_hash, :to_hash_groups
|
206
208
|
public_send(*prepared_type, &block)
|
207
209
|
end
|
data/lib/sequel/dataset/sql.rb
CHANGED
@@ -22,7 +22,7 @@ module Sequel
|
|
22
22
|
def insert_sql(*values)
|
23
23
|
return static_sql(@opts[:sql]) if @opts[:sql]
|
24
24
|
|
25
|
-
|
25
|
+
check_insert_allowed!
|
26
26
|
|
27
27
|
columns = []
|
28
28
|
|
@@ -172,7 +172,7 @@ module Sequel
|
|
172
172
|
# than one table.
|
173
173
|
def update_sql(values = OPTS)
|
174
174
|
return static_sql(opts[:sql]) if opts[:sql]
|
175
|
-
|
175
|
+
check_update_allowed!
|
176
176
|
check_not_limited!(:update)
|
177
177
|
|
178
178
|
case values
|
@@ -215,7 +215,7 @@ module Sequel
|
|
215
215
|
lines << "def #{'_' if priv}#{type}_sql"
|
216
216
|
lines << 'if sql = opts[:sql]; return static_sql(sql) end' unless priv
|
217
217
|
lines << "if sql = cache_get(:_#{type}_sql); return sql end" if cacheable
|
218
|
-
lines << '
|
218
|
+
lines << 'check_delete_allowed!' << 'check_not_limited!(:delete)' if type == :delete
|
219
219
|
lines << 'sql = @opts[:append_sql] || sql_string_origin'
|
220
220
|
|
221
221
|
if clauses.all?{|c| c.is_a?(Array)}
|
@@ -918,10 +918,35 @@ module Sequel
|
|
918
918
|
!@opts[:no_cache_sql] && !cache_get(:_no_cache_sql)
|
919
919
|
end
|
920
920
|
|
921
|
-
# Raise an InvalidOperation exception if
|
921
|
+
# Raise an InvalidOperation exception if modification is not allowed for this dataset.
|
922
|
+
# Check whether it is allowed to insert into this dataset.
|
923
|
+
# Only for backwards compatibility with older external adapters.
|
922
924
|
def check_modification_allowed!
|
925
|
+
# SEQUEL6: Remove
|
926
|
+
Sequel::Deprecation.deprecate("Dataset#check_modification_allowed!", "Use check_{insert,delete,update,truncation}_allowed! instead")
|
927
|
+
_check_modification_allowed!(supports_modifying_joins?)
|
928
|
+
end
|
929
|
+
|
930
|
+
# Check whether it is allowed to insert into this dataset.
|
931
|
+
def check_insert_allowed!
|
932
|
+
_check_modification_allowed!(false)
|
933
|
+
end
|
934
|
+
alias check_truncation_allowed! check_insert_allowed!
|
935
|
+
|
936
|
+
# Check whether it is allowed to delete from this dataset.
|
937
|
+
def check_delete_allowed!
|
938
|
+
_check_modification_allowed!(supports_deleting_joins?)
|
939
|
+
end
|
940
|
+
|
941
|
+
# Check whether it is allowed to update this dataset.
|
942
|
+
def check_update_allowed!
|
943
|
+
_check_modification_allowed!(supports_updating_joins?)
|
944
|
+
end
|
945
|
+
|
946
|
+
# Internals of the check_*_allowed! methods
|
947
|
+
def _check_modification_allowed!(modifying_joins_supported)
|
923
948
|
raise(InvalidOperation, "Grouped datasets cannot be modified") if opts[:group]
|
924
|
-
raise(InvalidOperation, "Joined datasets cannot be modified") if !
|
949
|
+
raise(InvalidOperation, "Joined datasets cannot be modified") if !modifying_joins_supported && joined_dataset?
|
925
950
|
end
|
926
951
|
|
927
952
|
# Raise error if the dataset uses limits or offsets.
|
@@ -930,11 +955,6 @@ module Sequel
|
|
930
955
|
raise InvalidOperation, "Dataset##{type} not supported on datasets with limits or offsets" if opts[:limit] || opts[:offset]
|
931
956
|
end
|
932
957
|
|
933
|
-
# Alias of check_modification_allowed!
|
934
|
-
def check_truncation_allowed!
|
935
|
-
check_modification_allowed!
|
936
|
-
end
|
937
|
-
|
938
958
|
# Append column list to SQL string.
|
939
959
|
# If the column list is empty, a wildcard (*) is appended.
|
940
960
|
def column_list_append(sql, columns)
|
@@ -971,7 +991,9 @@ module Sequel
|
|
971
991
|
# operators unsupported by some databases. Used by adapters for databases
|
972
992
|
# that don't support the operators natively.
|
973
993
|
def complex_expression_emulate_append(sql, op, args)
|
994
|
+
# :nocov:
|
974
995
|
case op
|
996
|
+
# :nocov:
|
975
997
|
when :%
|
976
998
|
complex_expression_arg_pairs_append(sql, args){|a, b| Sequel.function(:MOD, a, b)}
|
977
999
|
when :>>
|
@@ -6,6 +6,12 @@
|
|
6
6
|
#
|
7
7
|
# Sequel.extension :blank
|
8
8
|
|
9
|
+
[FalseClass, Object, NilClass, Numeric, String, TrueClass].each do |klass|
|
10
|
+
if klass.method_defined?(:blank?)
|
11
|
+
klass.send(:alias_method, :blank?, :blank?)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
class FalseClass
|
10
16
|
# false is always blank
|
11
17
|
def blank?
|
@@ -49,7 +49,10 @@ module Sequel
|
|
49
49
|
# Options:
|
50
50
|
# :cast :: Cast to the specified type instead of the default if casting
|
51
51
|
def date_sub(expr, interval, opts=OPTS)
|
52
|
-
|
52
|
+
if defined?(ActiveSupport::Duration) && interval.is_a?(ActiveSupport::Duration)
|
53
|
+
interval = interval.parts
|
54
|
+
end
|
55
|
+
interval = if interval.is_a?(Enumerable)
|
53
56
|
h = {}
|
54
57
|
interval.each{|k,v| h[k] = -v unless v.nil?}
|
55
58
|
h
|
@@ -113,12 +116,12 @@ module Sequel
|
|
113
116
|
end
|
114
117
|
when :mssql, :h2, :access, :sqlanywhere
|
115
118
|
units = case db_type
|
116
|
-
when :mssql, :sqlanywhere
|
117
|
-
MSSQL_DURATION_UNITS
|
118
119
|
when :h2
|
119
120
|
H2_DURATION_UNITS
|
120
121
|
when :access
|
121
122
|
ACCESS_DURATION_UNITS
|
123
|
+
else
|
124
|
+
MSSQL_DURATION_UNITS
|
122
125
|
end
|
123
126
|
each_valid_interval_unit(h, units) do |value, sql_unit|
|
124
127
|
expr = Sequel.function(:DATEADD, sql_unit, value, expr)
|
@@ -105,6 +105,12 @@ class String
|
|
105
105
|
yield Inflections if block_given?
|
106
106
|
Inflections
|
107
107
|
end
|
108
|
+
|
109
|
+
%w'classify constantize dasherize demodulize foreign_key humanize pluralize singularize tableize underscore'.each do |m|
|
110
|
+
if method_defined?(m)
|
111
|
+
alias_method(m, m)
|
112
|
+
end
|
113
|
+
end
|
108
114
|
|
109
115
|
# By default, camelize converts the string to UpperCamelCase. If the argument to camelize
|
110
116
|
# is set to :lower then camelize produces lowerCamelCase.
|
@@ -68,7 +68,9 @@ module Sequel
|
|
68
68
|
# Allow calling private methods for backwards compatibility
|
69
69
|
@db.send(method_sym, *args, &block)
|
70
70
|
end
|
71
|
+
# :nocov:
|
71
72
|
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
73
|
+
# :nocov:
|
72
74
|
|
73
75
|
# This object responds to all methods the database responds to.
|
74
76
|
def respond_to_missing?(meth, include_private)
|
@@ -213,6 +213,7 @@ module Sequel
|
|
213
213
|
scalar_typecast_method = :"typecast_value_#{opts.fetch(:scalar_typecast, type)}"
|
214
214
|
define_method(meth){|v| typecast_value_pg_array(v, creator, scalar_typecast_method)}
|
215
215
|
private meth
|
216
|
+
alias_method(meth, meth)
|
216
217
|
end
|
217
218
|
|
218
219
|
@schema_type_classes[:"#{type}_array"] = PGArray
|
@@ -34,6 +34,13 @@
|
|
34
34
|
|
35
35
|
require 'active_support/duration'
|
36
36
|
|
37
|
+
# :nocov:
|
38
|
+
begin
|
39
|
+
require 'active_support/version'
|
40
|
+
rescue LoadError
|
41
|
+
end
|
42
|
+
# :nocov:
|
43
|
+
|
37
44
|
module Sequel
|
38
45
|
module Postgres
|
39
46
|
module IntervalDatabaseMethods
|
@@ -61,34 +68,37 @@ module Sequel
|
|
61
68
|
|
62
69
|
# Creates callable objects that convert strings into ActiveSupport::Duration instances.
|
63
70
|
class Parser
|
71
|
+
# Whether ActiveSupport::Duration.new takes parts as array instead of hash
|
72
|
+
USE_PARTS_ARRAY = !defined?(ActiveSupport::VERSION::STRING) || ActiveSupport::VERSION::STRING < '5.1'
|
73
|
+
|
64
74
|
# Parse the interval input string into an ActiveSupport::Duration instance.
|
65
75
|
def call(string)
|
66
76
|
raise(InvalidValue, "invalid or unhandled interval format: #{string.inspect}") unless matches = /\A([+-]?\d+ years?\s?)?([+-]?\d+ mons?\s?)?([+-]?\d+ days?\s?)?(?:(?:([+-])?(\d{2,10}):(\d\d):(\d\d(\.\d+)?))|([+-]?\d+ hours?\s?)?([+-]?\d+ mins?\s?)?([+-]?\d+(\.\d+)? secs?\s?)?)?\z/.match(string)
|
67
77
|
|
68
78
|
value = 0
|
69
|
-
parts =
|
79
|
+
parts = {}
|
70
80
|
|
71
81
|
if v = matches[1]
|
72
82
|
v = v.to_i
|
73
83
|
value += 31557600 * v
|
74
|
-
parts
|
84
|
+
parts[:years] = v
|
75
85
|
end
|
76
86
|
if v = matches[2]
|
77
87
|
v = v.to_i
|
78
88
|
value += 2592000 * v
|
79
|
-
parts
|
89
|
+
parts[:months] = v
|
80
90
|
end
|
81
91
|
if v = matches[3]
|
82
92
|
v = v.to_i
|
83
93
|
value += 86400 * v
|
84
|
-
parts
|
94
|
+
parts[:days] = v
|
85
95
|
end
|
86
96
|
if matches[5]
|
87
97
|
seconds = matches[5].to_i * 3600 + matches[6].to_i * 60
|
88
98
|
seconds += matches[8] ? matches[7].to_f : matches[7].to_i
|
89
99
|
seconds *= -1 if matches[4] == '-'
|
90
100
|
value += seconds
|
91
|
-
parts
|
101
|
+
parts[:seconds] = seconds
|
92
102
|
elsif matches[9] || matches[10] || matches[11]
|
93
103
|
seconds = 0
|
94
104
|
if v = matches[9]
|
@@ -101,8 +111,14 @@ module Sequel
|
|
101
111
|
seconds += matches[12] ? v.to_f : v.to_i
|
102
112
|
end
|
103
113
|
value += seconds
|
104
|
-
parts
|
114
|
+
parts[:seconds] = seconds
|
115
|
+
end
|
116
|
+
|
117
|
+
# :nocov:
|
118
|
+
if USE_PARTS_ARRAY
|
119
|
+
parts = parts.to_a
|
105
120
|
end
|
121
|
+
# :nocov:
|
106
122
|
|
107
123
|
ActiveSupport::Duration.new(value, parts)
|
108
124
|
end
|
@@ -1930,6 +1930,7 @@ module Sequel
|
|
1930
1930
|
# super to be called.
|
1931
1931
|
def association_module_def(name, opts=OPTS, &block)
|
1932
1932
|
association_module(opts).send(:define_method, name, &block)
|
1933
|
+
association_module(opts).send(:alias_method, name, name)
|
1933
1934
|
end
|
1934
1935
|
|
1935
1936
|
# Add a private method to the module included in the class.
|
data/lib/sequel/model/base.rb
CHANGED
@@ -508,7 +508,9 @@ module Sequel
|
|
508
508
|
|
509
509
|
m.configure(self, *args, &block) if m.respond_to?(:configure)
|
510
510
|
end
|
511
|
+
# :nocov:
|
511
512
|
ruby2_keywords(:plugin) if respond_to?(:ruby2_keywords, true)
|
513
|
+
# :nocov:
|
512
514
|
|
513
515
|
# Returns primary key attribute hash. If using a composite primary key
|
514
516
|
# value such be an array with values for each primary key in the correct
|
@@ -727,8 +729,14 @@ module Sequel
|
|
727
729
|
im = instance_methods
|
728
730
|
overridable_methods_module.module_eval do
|
729
731
|
meth = :"#{column}="
|
730
|
-
|
731
|
-
|
732
|
+
unless im.include?(column)
|
733
|
+
define_method(column){self[column]}
|
734
|
+
alias_method(column, column)
|
735
|
+
end
|
736
|
+
unless im.include?(meth)
|
737
|
+
define_method(meth){|v| self[column] = v}
|
738
|
+
alias_method(meth, meth)
|
739
|
+
end
|
732
740
|
end
|
733
741
|
end
|
734
742
|
|
@@ -741,8 +749,14 @@ module Sequel
|
|
741
749
|
im = instance_methods
|
742
750
|
columns.each do |column|
|
743
751
|
meth = :"#{column}="
|
744
|
-
|
745
|
-
|
752
|
+
unless im.include?(column)
|
753
|
+
overridable_methods_module.module_eval("def #{column}; self[:#{column}] end", __FILE__, __LINE__)
|
754
|
+
overridable_methods_module.send(:alias_method, column, column)
|
755
|
+
end
|
756
|
+
unless im.include?(meth)
|
757
|
+
overridable_methods_module.module_eval("def #{meth}(v); self[:#{column}] = v end", __FILE__, __LINE__)
|
758
|
+
overridable_methods_module.send(:alias_method, meth, meth)
|
759
|
+
end
|
746
760
|
end
|
747
761
|
end
|
748
762
|
|
@@ -757,7 +771,10 @@ module Sequel
|
|
757
771
|
else
|
758
772
|
define_singleton_method(meth){|*args, &block| dataset.public_send(meth, *args, &block)}
|
759
773
|
end
|
774
|
+
singleton_class.send(:alias_method, meth, meth)
|
775
|
+
# :nocov:
|
760
776
|
singleton_class.send(:ruby2_keywords, meth) if respond_to?(:ruby2_keywords, true)
|
777
|
+
# :nocov:
|
761
778
|
end
|
762
779
|
|
763
780
|
# Get the schema from the database, fall back on checking the columns
|
data/lib/sequel/model/plugins.rb
CHANGED
@@ -31,7 +31,9 @@ module Sequel
|
|
31
31
|
def self.def_dataset_methods(mod, meths)
|
32
32
|
Array(meths).each do |meth|
|
33
33
|
mod.class_eval("def #{meth}(*args, &block); dataset.#{meth}(*args, &block) end", __FILE__, __LINE__)
|
34
|
+
# :nocov:
|
34
35
|
mod.send(:ruby2_keywords, meth) if respond_to?(:ruby2_keywords, true)
|
36
|
+
# :nocov:
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
@@ -120,6 +122,7 @@ module Sequel
|
|
120
122
|
|
121
123
|
model.send(:define_method, meth, &block)
|
122
124
|
model.send(:private, meth)
|
125
|
+
model.send(:alias_method, meth, meth)
|
123
126
|
call_meth
|
124
127
|
end
|
125
128
|
|
@@ -141,6 +144,8 @@ module Sequel
|
|
141
144
|
keyword = :required
|
142
145
|
when :key, :keyrest
|
143
146
|
keyword ||= true
|
147
|
+
else
|
148
|
+
raise Error, "invalid arg_type passed to _define_sequel_method_arg_numbers: #{arg_type}"
|
144
149
|
end
|
145
150
|
end
|
146
151
|
arity = callable.arity
|
@@ -143,10 +143,14 @@ module Sequel
|
|
143
143
|
compositions[name] = send(composer_meth)
|
144
144
|
end
|
145
145
|
end
|
146
|
-
|
146
|
+
alias_method(name, name)
|
147
|
+
|
148
|
+
meth = :"#{name}="
|
149
|
+
define_method(meth) do |v|
|
147
150
|
modified!
|
148
151
|
compositions[name] = v
|
149
152
|
end
|
153
|
+
alias_method(meth, meth)
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
@@ -62,7 +62,10 @@ module Sequel
|
|
62
62
|
ret = super
|
63
63
|
r = association_reflection(name)
|
64
64
|
meth = r.returns_array? ? name : pluralize(name).to_sym
|
65
|
-
dataset_module
|
65
|
+
dataset_module do
|
66
|
+
define_method(meth){associated(name)}
|
67
|
+
alias_method(meth, meth)
|
68
|
+
end
|
66
69
|
ret
|
67
70
|
end
|
68
71
|
|
@@ -145,9 +145,11 @@ module Sequel
|
|
145
145
|
# class.
|
146
146
|
def def_nested_attribute_method(reflection)
|
147
147
|
@nested_attributes_module.class_eval do
|
148
|
-
|
148
|
+
meth = :"#{reflection[:name]}_attributes="
|
149
|
+
define_method(meth) do |v|
|
149
150
|
set_nested_attributes(reflection[:name], v)
|
150
151
|
end
|
152
|
+
alias_method meth, meth
|
151
153
|
end
|
152
154
|
end
|
153
155
|
end
|
@@ -520,7 +520,9 @@ module Sequel
|
|
520
520
|
def many_to_pg_array_association_filter_expression(op, ref, obj)
|
521
521
|
pk = ref.qualify(model.table_name, ref.primary_key)
|
522
522
|
key = ref[:key]
|
523
|
+
# :nocov:
|
523
524
|
expr = case obj
|
525
|
+
# :nocov:
|
524
526
|
when Sequel::Model
|
525
527
|
if (assoc_pks = obj.get_column_value(key)) && !assoc_pks.empty?
|
526
528
|
Sequel[pk=>assoc_pks.to_a]
|
@@ -540,7 +542,9 @@ module Sequel
|
|
540
542
|
# Support filtering by pg_array_to_many associations using a subquery.
|
541
543
|
def pg_array_to_many_association_filter_expression(op, ref, obj)
|
542
544
|
key = ref.qualify(model.table_name, ref[:key_column])
|
545
|
+
# :nocov:
|
543
546
|
expr = case obj
|
547
|
+
# :nocov:
|
544
548
|
when Sequel::Model
|
545
549
|
if pkv = obj.get_column_value(ref.primary_key_method)
|
546
550
|
Sequel.pg_array_op(key).contains(Sequel.pg_array([pkv], ref.array_type))
|
@@ -250,7 +250,9 @@ module Sequel
|
|
250
250
|
messages = model.pg_auto_constraint_validations_messages
|
251
251
|
|
252
252
|
unless override
|
253
|
+
# :nocov:
|
253
254
|
case e
|
255
|
+
# :nocov:
|
254
256
|
when Sequel::NotNullConstraintViolation
|
255
257
|
if column = info[:column]
|
256
258
|
add_pg_constraint_validation_error([m.call(column)], messages[:not_null])
|
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 = 40
|
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.40.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: 2021-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -117,9 +117,8 @@ extra_rdoc_files:
|
|
117
117
|
- README.rdoc
|
118
118
|
- CHANGELOG
|
119
119
|
- MIT-LICENSE
|
120
|
-
- doc/association_basics.rdoc
|
121
|
-
- doc/model_dataset_method_design.rdoc
|
122
120
|
- doc/advanced_associations.rdoc
|
121
|
+
- doc/association_basics.rdoc
|
123
122
|
- doc/bin_sequel.rdoc
|
124
123
|
- doc/cheat_sheet.rdoc
|
125
124
|
- doc/code_order.rdoc
|
@@ -127,37 +126,30 @@ extra_rdoc_files:
|
|
127
126
|
- doc/dataset_basics.rdoc
|
128
127
|
- doc/dataset_filtering.rdoc
|
129
128
|
- doc/extensions.rdoc
|
129
|
+
- doc/fork_safety.rdoc
|
130
130
|
- doc/mass_assignment.rdoc
|
131
131
|
- doc/migration.rdoc
|
132
|
-
- doc/
|
132
|
+
- doc/model_dataset_method_design.rdoc
|
133
133
|
- doc/model_hooks.rdoc
|
134
134
|
- doc/model_plugins.rdoc
|
135
|
-
- doc/object_model.rdoc
|
136
|
-
- doc/sql.rdoc
|
137
135
|
- doc/mssql_stored_procedures.rdoc
|
138
|
-
- doc/
|
136
|
+
- doc/object_model.rdoc
|
137
|
+
- doc/opening_databases.rdoc
|
139
138
|
- doc/postgresql.rdoc
|
140
|
-
- doc/querying.rdoc
|
141
139
|
- doc/prepared_statements.rdoc
|
140
|
+
- doc/querying.rdoc
|
142
141
|
- doc/reflection.rdoc
|
143
|
-
- doc/security.rdoc
|
144
|
-
- doc/virtual_rows.rdoc
|
145
142
|
- doc/schema_modification.rdoc
|
143
|
+
- doc/security.rdoc
|
146
144
|
- doc/sharding.rdoc
|
145
|
+
- doc/sql.rdoc
|
147
146
|
- doc/testing.rdoc
|
148
|
-
- doc/
|
147
|
+
- doc/thread_safety.rdoc
|
149
148
|
- doc/transactions.rdoc
|
150
|
-
- doc/
|
151
|
-
- doc/
|
152
|
-
- doc/release_notes/5.6.0.txt
|
149
|
+
- doc/validations.rdoc
|
150
|
+
- doc/virtual_rows.rdoc
|
153
151
|
- doc/release_notes/5.0.0.txt
|
154
152
|
- doc/release_notes/5.1.0.txt
|
155
|
-
- doc/release_notes/5.2.0.txt
|
156
|
-
- doc/release_notes/5.3.0.txt
|
157
|
-
- doc/release_notes/5.4.0.txt
|
158
|
-
- doc/release_notes/5.8.0.txt
|
159
|
-
- doc/release_notes/5.7.0.txt
|
160
|
-
- doc/release_notes/5.9.0.txt
|
161
153
|
- doc/release_notes/5.10.0.txt
|
162
154
|
- doc/release_notes/5.11.0.txt
|
163
155
|
- doc/release_notes/5.12.0.txt
|
@@ -168,6 +160,7 @@ extra_rdoc_files:
|
|
168
160
|
- doc/release_notes/5.17.0.txt
|
169
161
|
- doc/release_notes/5.18.0.txt
|
170
162
|
- doc/release_notes/5.19.0.txt
|
163
|
+
- doc/release_notes/5.2.0.txt
|
171
164
|
- doc/release_notes/5.20.0.txt
|
172
165
|
- doc/release_notes/5.21.0.txt
|
173
166
|
- doc/release_notes/5.22.0.txt
|
@@ -178,6 +171,7 @@ extra_rdoc_files:
|
|
178
171
|
- doc/release_notes/5.27.0.txt
|
179
172
|
- doc/release_notes/5.28.0.txt
|
180
173
|
- doc/release_notes/5.29.0.txt
|
174
|
+
- doc/release_notes/5.3.0.txt
|
181
175
|
- doc/release_notes/5.30.0.txt
|
182
176
|
- doc/release_notes/5.31.0.txt
|
183
177
|
- doc/release_notes/5.32.0.txt
|
@@ -188,6 +182,13 @@ extra_rdoc_files:
|
|
188
182
|
- doc/release_notes/5.37.0.txt
|
189
183
|
- doc/release_notes/5.38.0.txt
|
190
184
|
- doc/release_notes/5.39.0.txt
|
185
|
+
- doc/release_notes/5.4.0.txt
|
186
|
+
- doc/release_notes/5.40.0.txt
|
187
|
+
- doc/release_notes/5.5.0.txt
|
188
|
+
- doc/release_notes/5.6.0.txt
|
189
|
+
- doc/release_notes/5.7.0.txt
|
190
|
+
- doc/release_notes/5.8.0.txt
|
191
|
+
- doc/release_notes/5.9.0.txt
|
191
192
|
files:
|
192
193
|
- CHANGELOG
|
193
194
|
- MIT-LICENSE
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- doc/release_notes/5.38.0.txt
|
251
252
|
- doc/release_notes/5.39.0.txt
|
252
253
|
- doc/release_notes/5.4.0.txt
|
254
|
+
- doc/release_notes/5.40.0.txt
|
253
255
|
- doc/release_notes/5.5.0.txt
|
254
256
|
- doc/release_notes/5.6.0.txt
|
255
257
|
- doc/release_notes/5.7.0.txt
|
@@ -555,7 +557,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
555
557
|
- !ruby/object:Gem::Version
|
556
558
|
version: '0'
|
557
559
|
requirements: []
|
558
|
-
rubygems_version: 3.
|
560
|
+
rubygems_version: 3.2.3
|
559
561
|
signing_key:
|
560
562
|
specification_version: 4
|
561
563
|
summary: The Database Toolkit for Ruby
|