activerecord-cockroachdb-adapter 6.1.5 → 6.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91f5211d32cfc503198148dab27748e66dc7fd86bd7d1916ed78a59879cc7235
4
- data.tar.gz: 69d4191eef0d08f6a472317413eb16abfcdb548e058c6d1074ca34c1a5ad21d4
3
+ metadata.gz: cddd7b77a75769847eedbbb0b7957a3602c76f0ecc1b55bf988caebf85404fa6
4
+ data.tar.gz: 884de42df8ac2f764529febc00208d7e3c8a0dbe4aec4c43e615c13b3b495eca
5
5
  SHA512:
6
- metadata.gz: a8702aea7fd32df17b58c68d5a29df99c3514784bb876dc1d49c36b98f824f8200a02e74f4f543ec51aaa1d8ff5da14729e155ee5b1223e0944a5768df309244
7
- data.tar.gz: 5980c011b221d6b23b96b7f0e4ec0050a991a83235ac975783b67d8543638e1e7b75b47e870ee720c0e4584ec739f312d2946aff8a1580dba46c49a6dab001d9
6
+ metadata.gz: 968b9d0b39f778413536feb3b2a1e740f3d785fcb6d472092eeba018c3a6d7b823ba2988aa69fa8571c2da4cf041b027e72b250f325b6377ed9a7f978e2ab53b
7
+ data.tar.gz: 21bf7f2cf7b58840b043c155588d3abb605b7b6a72732f9b04203616d5097c7468ead0752ebfc3196310f2fd248b67aed2efed49e751c3ceb4b328e7d333b310
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.8 - 2022-03-14
4
+
5
+ - Add a test helper from https://github.com/rails/rails/pull/40822
6
+ to be able to test against Rails upstream.
7
+
8
+ ## 6.1.7 - 2022-03-01
9
+
10
+ - Fix query to get the CockroachDB version so it does not require any privileges.
11
+
12
+ ## 6.1.6 - 2022-02-25
13
+
14
+ - Fix mixed versions of CockroachDB v21.1 and v21.2 not working.
15
+
3
16
  ## 6.1.5 - 2022-02-08
4
17
 
5
18
  - Support `atttypmod` being sent for DECIMAL types.
@@ -228,27 +228,42 @@ module ActiveRecord
228
228
  def initialize(connection, logger, conn_params, config)
229
229
  super(connection, logger, conn_params, config)
230
230
 
231
+ # crdb_version is the version of the binary running on the node. We
232
+ # really want to use `SHOW CLUSTER SETTING version` to get the cluster
233
+ # version, but that is only available to admins. Instead, we can use
234
+ # crdb_internal.is_at_least_version, but that's only available in 22.1.
231
235
  crdb_version_string = query_value("SHOW crdb_version")
232
- if crdb_version_string.include? "v1."
233
- version_num = 1
234
- elsif crdb_version_string.include? "v2."
235
- version_num 2
236
- elsif crdb_version_string.include? "v19.1."
237
- version_num = 1910
238
- elsif crdb_version_string.include? "v19.2."
239
- version_num = 1920
240
- elsif crdb_version_string.include? "v20.1."
241
- version_num = 2010
242
- elsif crdb_version_string.include? "v20.2."
243
- version_num = 2020
244
- elsif crdb_version_string.include? "v21.1."
245
- version_num = 2110
246
- elsif crdb_version_string.include? "v21.2.0"
247
- version_num = 2120
236
+ if crdb_version_string.include? "v22.1"
237
+ version_num = query_value(<<~SQL, "VERSION")
238
+ SELECT
239
+ CASE
240
+ WHEN crdb_internal.is_at_least_version('22.2') THEN 2220
241
+ WHEN crdb_internal.is_at_least_version('22.1') THEN 2210
242
+ ELSE 2120
243
+ END;
244
+ SQL
248
245
  else
249
- version_num = 2121
246
+ # This branch can be removed once the dialect stops supporting v21.2
247
+ # and earlier.
248
+ if crdb_version_string.include? "v1."
249
+ version_num = 1
250
+ elsif crdb_version_string.include? "v2."
251
+ version_num 2
252
+ elsif crdb_version_string.include? "v19.1."
253
+ version_num = 1910
254
+ elsif crdb_version_string.include? "v19.2."
255
+ version_num = 1920
256
+ elsif crdb_version_string.include? "v20.1."
257
+ version_num = 2010
258
+ elsif crdb_version_string.include? "v20.2."
259
+ version_num = 2020
260
+ elsif crdb_version_string.include? "v21.1."
261
+ version_num = 2110
262
+ else
263
+ version_num = 2120
264
+ end
250
265
  end
251
- @crdb_version = version_num
266
+ @crdb_version = version_num.to_i
252
267
 
253
268
  # NOTE: this is normally in configure_connection, but that is run
254
269
  # before crdb_version is determined. Once all supported versions
@@ -256,8 +271,14 @@ module ActiveRecord
256
271
  # back.
257
272
  # Set interval output format to ISO 8601 for ease of parsing by ActiveSupport::Duration.parse
258
273
  if @crdb_version >= 2120
259
- execute("SET intervalstyle_enabled = true", "SCHEMA")
260
- execute("SET intervalstyle = iso_8601", "SCHEMA")
274
+ begin
275
+ execute("SET intervalstyle_enabled = true", "SCHEMA")
276
+ execute("SET intervalstyle = iso_8601", "SCHEMA")
277
+ rescue
278
+ # Ignore any error. This can happen with a cluster that has
279
+ # not yet finalized the v21.2 upgrade. v21.2 does not have
280
+ # a way to tell if the upgrade was finalized (see comment above).
281
+ end
261
282
  end
262
283
  end
263
284
 
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecord
4
- COCKROACH_DB_ADAPTER_VERSION = "6.1.5"
4
+ COCKROACH_DB_ADAPTER_VERSION = "6.1.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cockroachdb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.5
4
+ version: 6.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cockroach Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-11 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord