sequel 5.52.0 → 5.53.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06302dbd32fc7e13539c83a4cf86fa72d974ffb15d403f30ca13d08af83c0605
4
- data.tar.gz: ad8cc158183399ac93c5a44e0e33d0693a92599ccb5092f542ff2993f4701d25
3
+ metadata.gz: 7cd8e3e9c13b3f5593389d91fafe25706716cb7810187db2d1301efb2a99ee96
4
+ data.tar.gz: f5d92dc333425438d63598d19119dc7ff06a2635756a9970bff2be8d5252477b
5
5
  SHA512:
6
- metadata.gz: 9b0943434af7e097bf7589ec885b6509f40b9677d7e1be56cac17f5093bc2c9a6c1e79918b547a4d04a2623b5562e4e8897247551f1a89ecde5c53339e6c9a48
7
- data.tar.gz: a82852fa8dd6b598b7463acafab29bd6d1b5e514b639e3d13ee33855c300d9daa662d4ea1af27525d7557644c2eb8bd1ccceec376aa6b1dc26286658db5b63e7
6
+ metadata.gz: 8e41100d1bec6bfa083ac57d52a4109bea07cda47d99c7b7b56e086489b36d9dde9361a3ee4b14795a11cdab4bc27d2fdb544a5df8bdc2e65c8df5a73bbf3ec0
7
+ data.tar.gz: 72be8971e7b44afb58b44115d654d24acb51c425b0019181ab495ffcd61ac23c497d108c6ed7982cddcb0c760270325a0cd1338f4265839bba571198f97e5ae2
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ === 5.53.0 (2022-02-01)
2
+
3
+ * Make Dataset#_sql_comment private when using the Database sql_comments extension (jeremyevans)
4
+
5
+ * Fix prepared statements in the mysql2 adapter to reuse native prepared statements (jeremyevans) (#1832)
6
+
7
+ * Support H2 version 2+ in the jdbc/h2 adapter (jeremyevans) (#1817)
8
+
9
+ * Work around active_support breaking subclasses plugin on Ruby <3.1 (jeremyevans) (#1816)
10
+
11
+ * Fix error handling if trying to setup column_encryption plugin without keys (jeremyevans) (#1815)
12
+
1
13
  === 5.52.0 (2022-01-01)
2
14
 
3
15
  * Use Class#subclasses if available in the subclasses plugin, instead of a custom Model.subclasses accessor (jeremyevans)
data/MIT-LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2007-2008 Sharon Rosner
2
- Copyright (c) 2008-2021 Jeremy Evans
2
+ Copyright (c) 2008-2022 Jeremy Evans
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to
@@ -0,0 +1,23 @@
1
+ = Improvements
2
+
3
+ * The jdbc/h2 subadapter now supports H2 version 2.0. It continues to
4
+ support H2 versions 1.3 and 1.4.
5
+
6
+ * The mysql2 adapter's prepared statement support now reuses existing
7
+ native prepared statements, instead of only binding variables on
8
+ newly prepared statements. This was the intended behavior
9
+ previously, and should result in increased performance in cases
10
+ where preparing a query takes significant time.
11
+
12
+ * The subclasses plugin now ignores an existing Class#subclasses
13
+ method if it is defined in Ruby. This fixes cases where usage of
14
+ ActiveSupport would break the subclasses plugin.
15
+
16
+ * Database#call_sproc in the jdbc adapter will now always close the
17
+ prepared call it creates. Before, if there was an exception raised
18
+ when setting the arguments for the prepared call, the prepared call
19
+ would not be closed.
20
+
21
+ * A more appropriate error is now issued if you try to use the
22
+ column_encryption plugin to encrypt a column without setting up an
23
+ encryption key.
@@ -24,6 +24,7 @@ module Sequel
24
24
 
25
25
  def freeze
26
26
  h2_version
27
+ version2?
27
28
  super
28
29
  end
29
30
 
@@ -140,13 +141,36 @@ module Sequel
140
141
  DATABASE_ERROR_REGEXPS
141
142
  end
142
143
 
143
- # Use IDENTITY() to get the last inserted id.
144
+ def execute_statement_insert(stmt, sql)
145
+ stmt.executeUpdate(sql, JavaSQL::Statement::RETURN_GENERATED_KEYS)
146
+ end
147
+
148
+ def prepare_jdbc_statement(conn, sql, opts)
149
+ opts[:type] == :insert ? conn.prepareStatement(sql, JavaSQL::Statement::RETURN_GENERATED_KEYS) : super
150
+ end
151
+
152
+ # Get the last inserted id using getGeneratedKeys, scope_identity, or identity.
144
153
  def last_insert_id(conn, opts=OPTS)
145
- statement(conn) do |stmt|
146
- sql = 'SELECT IDENTITY();'
147
- rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
148
- rs.next
149
- rs.getLong(1)
154
+ if stmt = opts[:stmt]
155
+ rs = stmt.getGeneratedKeys
156
+ begin
157
+ if rs.next
158
+ begin
159
+ rs.getLong(1)
160
+ rescue
161
+ rs.getObject(1) rescue nil
162
+ end
163
+ end
164
+ ensure
165
+ rs.close
166
+ end
167
+ elsif !version2?
168
+ statement(conn) do |stmt|
169
+ sql = 'SELECT IDENTITY()'
170
+ rs = log_connection_yield(sql, conn){stmt.executeQuery(sql)}
171
+ rs.next
172
+ rs.getLong(1)
173
+ end
150
174
  end
151
175
  end
152
176
 
@@ -161,7 +185,12 @@ module Sequel
161
185
 
162
186
  # Use BIGINT IDENTITY for identity columns that use :Bignum type
163
187
  def type_literal_generic_bignum_symbol(column)
164
- column[:identity] ? 'BIGINT IDENTITY' : super
188
+ column[:identity] ? 'BIGINT AUTO_INCREMENT' : super
189
+ end
190
+
191
+ def version2?
192
+ return @version2 if defined?(@version2)
193
+ @version2 = h2_version.to_i >= 2
165
194
  end
166
195
  end
167
196
 
@@ -209,9 +238,21 @@ module Sequel
209
238
 
210
239
  # H2 expects hexadecimal strings for blob values
211
240
  def literal_blob_append(sql, v)
212
- sql << "'" << v.unpack("H*").first << "'"
241
+ if db.send(:version2?)
242
+ super
243
+ else
244
+ sql << "'" << v.unpack("H*").first << "'"
245
+ end
246
+ end
247
+
248
+ def literal_false
249
+ 'FALSE'
213
250
  end
214
251
 
252
+ def literal_true
253
+ 'TRUE'
254
+ end
255
+
215
256
  # H2 handles fractional seconds in timestamps, but not in times
216
257
  def literal_sqltime(v)
217
258
  v.strftime("'%H:%M:%S'")
@@ -223,8 +264,12 @@ module Sequel
223
264
  end
224
265
 
225
266
  def select_only_offset_sql(sql)
226
- sql << " LIMIT -1 OFFSET "
227
- literal_append(sql, @opts[:offset])
267
+ if db.send(:version2?)
268
+ super
269
+ else
270
+ sql << " LIMIT -1 OFFSET "
271
+ literal_append(sql, @opts[:offset])
272
+ end
228
273
  end
229
274
 
230
275
  # H2 supports quoted function names.
@@ -188,12 +188,12 @@ module Sequel
188
188
  args = opts[:args] || []
189
189
  sql = "{call #{name}(#{args.map{'?'}.join(',')})}"
190
190
  synchronize(opts[:server]) do |conn|
191
- cps = conn.prepareCall(sql)
191
+ begin
192
+ cps = conn.prepareCall(sql)
192
193
 
193
- i = 0
194
- args.each{|arg| set_ps_arg(cps, arg, i+=1)}
194
+ i = 0
195
+ args.each{|arg| set_ps_arg(cps, arg, i+=1)}
195
196
 
196
- begin
197
197
  if defined?(yield)
198
198
  yield log_connection_yield(sql, conn){cps.executeQuery}
199
199
  else
@@ -205,7 +205,7 @@ module Sequel
205
205
  rescue *DATABASE_ERROR_CLASSES => e
206
206
  raise_error(e)
207
207
  ensure
208
- cps.close
208
+ cps.close if cps
209
209
  end
210
210
  end
211
211
  end
@@ -86,20 +86,26 @@ module Sequel
86
86
  if NativePreparedStatements
87
87
  # Use a native mysql2 prepared statement to implement prepared statements.
88
88
  def execute_prepared_statement(ps_name, opts, &block)
89
- ps = prepared_statement(ps_name)
89
+ if ps_name.is_a?(Sequel::Dataset::ArgumentMapper)
90
+ ps = ps_name
91
+ ps_name = ps.prepared_statement_name
92
+ else
93
+ ps = prepared_statement(ps_name)
94
+ end
90
95
  sql = ps.prepared_sql
91
96
 
92
97
  synchronize(opts[:server]) do |conn|
93
98
  stmt, ps_sql = conn.prepared_statements[ps_name]
94
99
  unless ps_sql == sql
95
100
  stmt.close if stmt
96
- stmt = log_connection_yield(conn, "Preparing #{ps_name}: #{sql}"){conn.prepare(sql)}
101
+ stmt = log_connection_yield("Preparing #{ps_name}: #{sql}", conn){conn.prepare(sql)}
97
102
  conn.prepared_statements[ps_name] = [stmt, sql]
98
103
  end
99
104
 
100
- if ps.log_sql
101
- opts = Hash[opts]
102
- opts = opts[:log_sql] = " (#{sql})"
105
+ opts = Hash[opts]
106
+ opts[:sql] = "Executing #{ps_name || sql}"
107
+ if ps_name && ps.log_sql
108
+ opts[:log_sql] = " (#{sql})"
103
109
  end
104
110
 
105
111
  _execute(conn, stmt, opts, &block)
@@ -120,6 +126,7 @@ module Sequel
120
126
  case sql
121
127
  when ::Mysql2::Statement
122
128
  stmt = sql
129
+ sql = opts[:sql] || ''
123
130
  when Dataset
124
131
  sql = sql.sql
125
132
  close_stmt = true
@@ -34,7 +34,7 @@ module Sequel
34
34
  def execute(sql, opts=OPTS, &block)
35
35
  if opts[:sproc]
36
36
  call_sproc(sql, opts, &block)
37
- elsif sql.is_a?(Symbol)
37
+ elsif sql.is_a?(Symbol) || sql.is_a?(Sequel::Dataset::ArgumentMapper)
38
38
  execute_prepared_statement(sql, opts, &block)
39
39
  else
40
40
  synchronize(opts[:server]){|conn| _execute(conn, sql, opts, &block)}
@@ -108,7 +108,7 @@ module Sequel
108
108
 
109
109
  # Call the ANY function:
110
110
  #
111
- # array_op.all # ANY(array)
111
+ # array_op.any # ANY(array)
112
112
  #
113
113
  # Usually used like:
114
114
  #
@@ -170,6 +170,8 @@ module Sequel
170
170
  module DatasetSQLComments
171
171
  include Sequel::SQLComments
172
172
 
173
+ private
174
+
173
175
  # Include comments added via Database#with_comments in the output SQL.
174
176
  def _sql_comment
175
177
  specific_comment = super
@@ -356,7 +356,7 @@ module Sequel
356
356
 
357
357
  # Keys should be an array of arrays containing key_id, key string, auth_data, and padding.
358
358
  def initialize(keys)
359
- if keys.empty?
359
+ if !keys || keys.empty?
360
360
  raise Error, "Cannot initialize encryptor without encryption key"
361
361
  end
362
362
 
@@ -35,7 +35,7 @@ module Sequel
35
35
  # class B < Sequel::Model; end
36
36
  # a # => [A, B]
37
37
  module Subclasses
38
- NEED_SUBCLASSES = !Object.respond_to?(:subclasses)
38
+ NEED_SUBCLASSES = !Object.respond_to?(:subclasses) || Object.method(:subclasses).source_location
39
39
  private_constant :NEED_SUBCLASSES
40
40
 
41
41
  # Initialize the subclasses instance variable for the model.
@@ -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 = 52
9
+ MINOR = 53
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.52.0
4
+ version: 5.53.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-01-01 00:00:00.000000000 Z
11
+ date: 2022-02-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.50.0.txt
198
198
  - doc/release_notes/5.51.0.txt
199
199
  - doc/release_notes/5.52.0.txt
200
+ - doc/release_notes/5.53.0.txt
200
201
  - doc/release_notes/5.6.0.txt
201
202
  - doc/release_notes/5.7.0.txt
202
203
  - doc/release_notes/5.8.0.txt
@@ -277,6 +278,7 @@ files:
277
278
  - doc/release_notes/5.50.0.txt
278
279
  - doc/release_notes/5.51.0.txt
279
280
  - doc/release_notes/5.52.0.txt
281
+ - doc/release_notes/5.53.0.txt
280
282
  - doc/release_notes/5.6.0.txt
281
283
  - doc/release_notes/5.7.0.txt
282
284
  - doc/release_notes/5.8.0.txt