sequel 5.37.0 → 5.38.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: a8314ec290f56d764f7d072c3982407c7478c4f762248cee2243b74dc82a6a31
4
- data.tar.gz: 4df47669ee1ff9f2a93ad6aaca195f168a7fa61572fe77347af9959eea6e025a
3
+ metadata.gz: 0f1a5546546a02086c315afdb93e50fb2df1f12ee665f048cd36589bff6da6cd
4
+ data.tar.gz: f42f5a4ec65f1ed13de8f01f8091673688346be075fee60507adc13473e8528f
5
5
  SHA512:
6
- metadata.gz: 6b1d811a54e04b79b92c96a8a93f6d1b714dc15451790f4db6a8e0f7f133be1d7350fa46a30448445089aa5cada2c05270bc6382d36e89a6e2d1a9efd5ceec2c
7
- data.tar.gz: dce7a9c8cda4f7498de3af2fe999e8ed3b1566d7022b1274352ce397eca96c8b234dfe13549ed0e613e24effa3519b46cd3c037b7abe62ce84367396ce7f71c7
6
+ metadata.gz: 5838cb5c5a9b24ba5646967a88bc4d487b99e760f8112ab455f0fb19dcfbd63cf884e1032bc31055eaeb0d1a89ab7d61b0865f89bfa35587b13ef4060fc8348c
7
+ data.tar.gz: d113cbddf7ccc677e0b43dd919fccdf3461d3f2157374b37cf89cfb1ce5f3156d43aab2bfcd9498ff99500bcd5fcd350fb8424894141a02cd648be128f36d0fc
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ === 5.38.0 (2020-11-01)
2
+
3
+ * Do not add new Database instances to Sequel::DATABASES if the test connection fails (jeremyevans) (#1727)
4
+
5
+ * Support the newer com.mysql.cj.jdbc.Driver in the jdbc/mysql adapter (jeremyevans)
6
+
7
+ * Do not swallow disconnect errors in Database#create_or_replace_view or Database#create_table* on Oracle (jeremyevans)
8
+
9
+ * Only rescue non-disconnect Sequel::DatabaseErrors in Postgres::Database#server_version (jeremyevans) (#1724)
10
+
11
+ * Make the single_table_inheritance and prepared_statements plugins work if loaded into the same class (jeremyevans) (#1721)
12
+
1
13
  === 5.37.0 (2020-10-01)
2
14
 
3
15
  * Recognize more unsigned decimal/float types in the schema dumper (akimd, jeremyevans) (#1720)
@@ -208,7 +208,7 @@ Example connection strings:
208
208
 
209
209
  jdbc:sqlite::memory:
210
210
  jdbc:postgresql://localhost/database?user=username
211
- jdbc:mysql://localhost/test?user=root&password=root
211
+ jdbc:mysql://localhost/test?user=root&password=root&serverTimezone=UTC
212
212
  jdbc:h2:mem:
213
213
  jdbc:hsqldb:mem:mymemdb
214
214
  jdbc:derby:memory:myDb;create=true
@@ -240,6 +240,10 @@ The following additional options are supported:
240
240
  There are a few issues with specific jdbc driver gems:
241
241
 
242
242
  jdbc-h2 :: jdbc-h2 versions greater than 1.3.175 have issues with ORDER BY not working correctly in some cases.
243
+ jdbc-mysql :: Depending on the configuration of the MySQL server, jdbc-mysql versions greater 8 may complain
244
+ about the server time zone being unrecognized. You can either use an older jdbc-mysql version,
245
+ or you can specify the +serverTimezone+ option in the connection string, as shown in the example
246
+ jdbc:mysql connection string above.
243
247
 
244
248
  === mysql
245
249
 
@@ -0,0 +1,28 @@
1
+ = New Features
2
+
3
+ * The jdbc/mysql adapter now supports the newer
4
+ com.mysql.cj.jdbc.Driver driver. The adapter will still attempt to
5
+ load the older com.mysql.jdbc.Driver if the com.mysql.cj.jdbc.Driver
6
+ is not found.
7
+
8
+ = Other Improvements
9
+
10
+ * When testing a connection after creating a new Database instance
11
+ raises an exception, the Database instance is removed from
12
+ Sequel::DATABASES.
13
+
14
+ * The single_table_inheritance and prepared_statements plugins now
15
+ work correctly if loaded into the same class.
16
+
17
+ * Database connect and disconnect errors are no longer swallowed when
18
+ calling Database#create_or_replace_view, Database#server_version
19
+ on PostgreSQL, or Database#create_table* on Oracle.
20
+
21
+ = Backwards Compatibility
22
+
23
+ * Previously, instantiating a new Database instance directly using
24
+ Sequel::Database.new did not test the connection by default. That
25
+ was instead handled by Sequel::Database.connect. The test
26
+ connection now happens inside Database#initialize. This should only
27
+ affect backwards compatibility for code that is calling
28
+ Sequel::Database.new directly.
@@ -51,7 +51,19 @@ module Sequel
51
51
  # Raise a Sequel::AdapterNotFound if evaluating the class name raises a NameError.
52
52
  def self.load_driver(drv, gem=nil)
53
53
  load_gem(gem) if gem
54
- eval drv
54
+ if drv.is_a?(String)
55
+ eval drv
56
+ else
57
+ *try, last = drv
58
+ try.each do |try_drv|
59
+ begin
60
+ return eval(try_drv)
61
+ rescue NameError
62
+ end
63
+ end
64
+
65
+ eval last
66
+ end
55
67
  rescue NameError
56
68
  raise Sequel::AdapterNotFound, "#{drv} not loaded#{", try installing jdbc-#{gem.to_s.downcase} gem" if gem}"
57
69
  end
@@ -1,15 +1,15 @@
1
1
  # frozen-string-literal: true
2
2
 
3
- Sequel::JDBC.load_driver('com.mysql.jdbc.Driver', :MySQL)
4
- require_relative '../shared/mysql'
5
-
6
3
  module Sequel
7
4
  module JDBC
5
+ driver = Sequel::JDBC.load_driver(%w'com.mysql.cj.jdbc.Driver com.mysql.jdbc.Driver', :MySQL)
6
+ require_relative '../shared/mysql'
7
+
8
8
  Sequel.synchronize do
9
9
  DATABASE_SETUP[:mysql] = proc do |db|
10
10
  db.extend(Sequel::JDBC::MySQL::DatabaseMethods)
11
11
  db.extend_datasets Sequel::MySQL::DatasetMethods
12
- com.mysql.jdbc.Driver
12
+ driver
13
13
  end
14
14
  end
15
15
 
@@ -184,7 +184,7 @@ module Sequel
184
184
 
185
185
  def create_table_from_generator(name, generator, options)
186
186
  drop_statement, create_statements = create_table_sql_list(name, generator, options)
187
- (execute_ddl(drop_statement) rescue nil) if drop_statement
187
+ swallow_database_error{execute_ddl(drop_statement)} if drop_statement
188
188
  create_statements.each{|sql| execute_ddl(sql)}
189
189
  end
190
190
 
@@ -781,7 +781,7 @@ module Sequel
781
781
  return @server_version if @server_version
782
782
  ds = dataset
783
783
  ds = ds.server(server) if server
784
- @server_version ||= ds.with_sql("SELECT CAST(current_setting('server_version_num') AS integer) AS v").single_value rescue 0
784
+ @server_version = swallow_database_error{ds.with_sql("SELECT CAST(current_setting('server_version_num') AS integer) AS v").single_value} || 0
785
785
  end
786
786
 
787
787
  # PostgreSQL supports CREATE TABLE IF NOT EXISTS on 9.1+
@@ -55,7 +55,6 @@ module Sequel
55
55
 
56
56
  begin
57
57
  db = c.new(opts)
58
- db.test_connection if db.send(:typecast_value_boolean, opts.fetch(:test, true))
59
58
  if block_given?
60
59
  return yield(db)
61
60
  end
@@ -166,6 +166,7 @@ module Sequel
166
166
  end
167
167
 
168
168
  initialize_load_extensions(:extensions)
169
+ test_connection if typecast_value_boolean(@opts.fetch(:test, true)) && respond_to?(:connect, true)
169
170
  rescue
170
171
  Sequel.synchronize{::Sequel::DATABASES.delete(self)} if keep_reference
171
172
  raise
@@ -446,6 +447,19 @@ module Sequel
446
447
  end
447
448
  end
448
449
 
450
+ # Swallow database errors, unless they are connect/disconnect errors.
451
+ def swallow_database_error
452
+ yield
453
+ rescue Sequel::DatabaseDisconnectError, DatabaseConnectionError
454
+ # Always raise disconnect errors
455
+ raise
456
+ rescue Sequel::DatabaseError
457
+ # Don't raise other database errors.
458
+ nil
459
+ # else
460
+ # Don't rescue other exceptions, they will be raised normally.
461
+ end
462
+
449
463
  # Typecast the value to an SQL::Blob
450
464
  def typecast_value_blob(value)
451
465
  value.is_a?(Sequel::SQL::Blob) ? value : Sequel::SQL::Blob.new(value)
@@ -240,7 +240,7 @@ module Sequel
240
240
  if supports_create_or_replace_view?
241
241
  options = options.merge(:replace=>true)
242
242
  else
243
- drop_view(name) rescue nil
243
+ swallow_database_error{drop_view(name)}
244
244
  end
245
245
 
246
246
  create_view(name, source, options)
@@ -433,11 +433,6 @@ module Sequel
433
433
  end
434
434
  end
435
435
  end
436
-
437
- # Don't allow use of prepared statements.
438
- def use_prepared_statements_for?(type)
439
- false
440
- end
441
436
  end
442
437
  end
443
438
  end
@@ -187,7 +187,6 @@ module Sequel
187
187
  end
188
188
  end
189
189
 
190
- # Manually specify that a column will change. This should only be used
191
190
  # Manually specify that a column will change. This should only be used
192
191
  # if you plan to modify a column value in place, which is not recommended.
193
192
  #
@@ -250,6 +250,11 @@ module Sequel
250
250
  end
251
251
  super
252
252
  end
253
+
254
+ # Don't allow use of prepared statements.
255
+ def use_prepared_statements_for?(type)
256
+ false
257
+ end
253
258
  end
254
259
  end
255
260
  end
@@ -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 = 37
9
+ MINOR = 38
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.37.0
4
+ version: 5.38.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: 2020-10-01 00:00:00.000000000 Z
11
+ date: 2020-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -185,6 +185,7 @@ extra_rdoc_files:
185
185
  - doc/release_notes/5.35.0.txt
186
186
  - doc/release_notes/5.36.0.txt
187
187
  - doc/release_notes/5.37.0.txt
188
+ - doc/release_notes/5.38.0.txt
188
189
  files:
189
190
  - CHANGELOG
190
191
  - MIT-LICENSE
@@ -243,6 +244,7 @@ files:
243
244
  - doc/release_notes/5.35.0.txt
244
245
  - doc/release_notes/5.36.0.txt
245
246
  - doc/release_notes/5.37.0.txt
247
+ - doc/release_notes/5.38.0.txt
246
248
  - doc/release_notes/5.4.0.txt
247
249
  - doc/release_notes/5.5.0.txt
248
250
  - doc/release_notes/5.6.0.txt
@@ -549,7 +551,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
549
551
  - !ruby/object:Gem::Version
550
552
  version: '0'
551
553
  requirements: []
552
- rubygems_version: 3.1.2
554
+ rubygems_version: 3.1.4
553
555
  signing_key:
554
556
  specification_version: 4
555
557
  summary: The Database Toolkit for Ruby