activerecord-cockroachdb-adapter 6.1.8 → 7.0.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: cddd7b77a75769847eedbbb0b7957a3602c76f0ecc1b55bf988caebf85404fa6
4
- data.tar.gz: 884de42df8ac2f764529febc00208d7e3c8a0dbe4aec4c43e615c13b3b495eca
3
+ metadata.gz: c8f39021d1353c56c2830adac978ec3336f993bdb46e670f4c975be8d2c307c5
4
+ data.tar.gz: 8ea587bc12a5e5bc806901d28c7e67e9f63a0c2f5dfc769f2370ab4dd3f20c65
5
5
  SHA512:
6
- metadata.gz: 968b9d0b39f778413536feb3b2a1e740f3d785fcb6d472092eeba018c3a6d7b823ba2988aa69fa8571c2da4cf041b027e72b250f325b6377ed9a7f978e2ab53b
7
- data.tar.gz: 21bf7f2cf7b58840b043c155588d3abb605b7b6a72732f9b04203616d5097c7468ead0752ebfc3196310f2fd248b67aed2efed49e751c3ceb4b328e7d333b310
6
+ metadata.gz: 6c7fca690e7203047ffeac709b9a62165c96f3ccb7ec26f3fe412daffc979f62ec392117912e15af15865aacf9f2b09bf2ff4d2efc155ee1f3dcbef1b2a213bb
7
+ data.tar.gz: 55cf42b3a055eabbec2045dac6650d50a96a085794dc2ef6bbb08efb44182daff7664720292f720099c3b08239edafbe1ae668779aa975426d9d8905fe98620b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.0.0 - 2022-06-02
4
+
5
+ - Add support for Active Record 7.0.3
6
+
7
+ ## 6.1.10 - 2022-05-06
8
+
9
+ - Disable supports_expression_index regardless of CockroachDB version until
10
+ `ON CONFLICT expression` is supported.
11
+
12
+ See https://github.com/cockroachdb/cockroach/issues/67893.
13
+
14
+ ## 6.1.9 - 2022-04-26
15
+
16
+ - Fix bug where duplicate `rowid` columns would be created when loading
17
+ a schema dump of a table that was not created with an explicit primary key.
18
+ - Support the NOT VISIBLE syntax from CockroachDB, by using the `hidden`
19
+ column modifier in the Rails schema.
20
+
3
21
  ## 6.1.8 - 2022-03-14
4
22
 
5
23
  - Add a test helper from https://github.com/rails/rails/pull/40822
@@ -32,7 +50,7 @@
32
50
 
33
51
  ## 6.1.1 - 2021-05-14
34
52
 
35
- - Fix a bug where starting the driver can result in a NoDatabaseError.
53
+ - Fix a bug where starting the driver can result in a NoDatabaseError.
36
54
 
37
55
  ## 6.1.0 - 2021-04-26
38
56
 
data/Gemfile CHANGED
@@ -54,10 +54,12 @@ end
54
54
 
55
55
  group :development do
56
56
  gem "byebug"
57
- gem "minitest-excludes"
57
+ gem "minitest-excludes", "~> 2.0.1"
58
58
 
59
59
  # Gems used by the ActiveRecord test suite
60
- gem "bcrypt"
61
- gem "mocha"
62
- gem "sqlite3"
60
+ gem "bcrypt", "~> 3.1.18"
61
+ gem "mocha", "~> 1.14.0"
62
+ gem "sqlite3", "~> 1.4.4"
63
+
64
+ gem "minitest", "~> 5.15.0"
63
65
  end
data/README.md CHANGED
@@ -1,19 +1,21 @@
1
1
  # ActiveRecord CockroachDB Adapter
2
2
 
3
- CockroachDB adapter for ActiveRecord 5 and 6. This is a lightweight extension of the PostgreSQL adapter that establishes compatibility with [CockroachDB](https://github.com/cockroachdb/cockroach).
3
+ CockroachDB adapter for ActiveRecord 5, 6, and 7. This is a lightweight extension of the PostgreSQL adapter that establishes compatibility with [CockroachDB](https://github.com/cockroachdb/cockroach).
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your project's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'activerecord-cockroachdb-adapter', '~> 6.1.0'
10
+ gem 'activerecord-cockroachdb-adapter', '~> 7.0.0'
11
11
  ```
12
12
 
13
13
  If you're using Rails 5.2, use the `5.2.x` versions of this gem.
14
14
 
15
15
  If you're using Rails 6.0, use the `6.0.x` versions of this gem.
16
16
 
17
+ If you're using Rails 7.0, use the `7.0.x` versions of this gem.
18
+
17
19
  In `database.yml`, use the following adapter setting:
18
20
 
19
21
  ```
@@ -17,10 +17,12 @@ Gem::Specification.new do |spec|
17
17
  spec.description = "Allows the use of CockroachDB as a backend for ActiveRecord and Rails apps."
18
18
  spec.homepage = "https://github.com/cockroachdb/activerecord-cockroachdb-adapter"
19
19
 
20
- spec.add_dependency "activerecord", "~> 6.1"
20
+ spec.add_dependency "activerecord", "~> 7.0.3"
21
21
  spec.add_dependency "pg", "~> 1.2"
22
22
  spec.add_dependency "rgeo-activerecord", "~> 7.0.0"
23
23
 
24
+ spec.add_development_dependency "benchmark-ips", "~> 2.9.1"
25
+
24
26
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
25
27
  # to allow pushing to a single host or delete this section to allow pushing to any host.
26
28
  if spec.respond_to?(:metadata)
@@ -3,7 +3,7 @@
3
3
  set -euox pipefail
4
4
 
5
5
  # Download CockroachDB
6
- VERSION=v21.2.5
6
+ VERSION=v22.1.0
7
7
  wget -qO- https://binaries.cockroachdb.com/cockroach-$VERSION.linux-amd64.tgz | tar xvz
8
8
  readonly COCKROACH=./cockroach-$VERSION.linux-amd64/cockroach
9
9
 
@@ -35,6 +35,8 @@ run_cockroach() {
35
35
  cockroach sql --insecure -e 'CREATE DATABASE activerecord_unittest2;'
36
36
  cockroach sql --insecure -e 'SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;'
37
37
  cockroach sql --insecure -e 'SET CLUSTER SETTING sql.stats.histogram_collection.enabled = false;'
38
+ cockroach sql --insecure -e "SET CLUSTER SETTING jobs.retention_time = '180s';"
39
+ cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.experimental_alter_column_type.enabled = 'true'"
38
40
 
39
41
  cockroach sql --insecure -e "ALTER RANGE default CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
40
42
  cockroach sql --insecure -e "ALTER TABLE system.public.jobs CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;"
@@ -46,21 +48,14 @@ run_cockroach() {
46
48
  cockroach sql --insecure -e "SET CLUSTER SETTING kv.raft_log.disable_synchronization_unsafe = 'true'"
47
49
  cockroach sql --insecure -e "SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';"
48
50
  cockroach sql --insecure -e "SET CLUSTER SETTING jobs.registry.interval.gc = '30s';"
49
- cockroach sql --insecure -e "SET CLUSTER SETTING jobs.retention_time = '15s';"
50
- cockroach sql --insecure -e "SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;"
51
51
  cockroach sql --insecure -e "SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';"
52
52
 
53
- # Enable when we test with v22.1.
54
- # cockroach sql --insecure -e "SET CLUSTER SETTING sql.catalog.unsafe_skip_system_config_trigger.enabled = true;"
55
-
56
53
  # Enable experimental features.
57
54
  cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';"
58
- cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.datestyle.enabled = true"
59
- cockroach sql --insecure -e "SET CLUSTER SETTING sql.defaults.intervalstyle.enabled = true;"
60
55
  }
61
56
 
62
57
  # Install ruby dependencies.
63
- gem install bundler:2.1.4
58
+ gem install bundler:2.3.14
64
59
  bundle install
65
60
 
66
61
  run_cockroach
@@ -6,9 +6,10 @@ module ActiveRecord
6
6
  # https://github.com/rgeo/activerecord-postgis-adapter/blob/master/lib/active_record/connection_adapters/postgis/spatial_column.rb
7
7
  def initialize(name, default, sql_type_metadata = nil, null = true,
8
8
  default_function = nil, collation: nil, comment: nil,
9
- serial: nil, spatial: nil)
9
+ serial: nil, spatial: nil, generated: nil, hidden: nil)
10
10
  @sql_type_metadata = sql_type_metadata
11
11
  @geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
12
+ @hidden = hidden
12
13
 
13
14
  if spatial
14
15
  # This case comes from an entry in the geometry_columns table
@@ -29,7 +30,7 @@ module ActiveRecord
29
30
  build_from_sql_type(sql_type_metadata.sql_type)
30
31
  end
31
32
  super(name, default, sql_type_metadata, null, default_function,
32
- collation: collation, comment: comment, serial: serial)
33
+ collation: collation, comment: comment, serial: serial, generated: generated)
33
34
  if spatial? && @srid
34
35
  @limit = { srid: @srid, type: to_type_name(geometric_type) }
35
36
  @limit[:has_z] = true if @has_z
@@ -52,6 +53,14 @@ module ActiveRecord
52
53
  spatial? ? @limit : super
53
54
  end
54
55
 
56
+ def virtual?
57
+ @generated.present?
58
+ end
59
+
60
+ def hidden?
61
+ @hidden
62
+ end
63
+
55
64
  def spatial?
56
65
  %i[geometry geography].include?(@sql_type_metadata.type)
57
66
  end
@@ -12,7 +12,8 @@ module ActiveRecord
12
12
  {
13
13
  read_committed: "READ COMMITTED",
14
14
  repeatable_read: "REPEATABLE READ",
15
- serializable: "SERIALIZABLE"
15
+ serializable: "SERIALIZABLE",
16
+ read_uncommitted: "READ UNCOMMITTED"
16
17
  }
17
18
  end
18
19
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module CockroachDB
6
+ module OID
7
+ module DateTime
8
+ protected
9
+
10
+ # override
11
+ # Uses CockroachDBAdapter instead of PostgreSQLAdapter
12
+ def real_type_unless_aliased(real_type)
13
+ ActiveRecord::ConnectionAdapters::CockroachDBAdapter.datetime_type == real_type ? :datetime : real_type
14
+ end
15
+ end
16
+
17
+ PostgreSQL::OID::DateTime.prepend(DateTime)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,8 +2,6 @@ module ActiveRecord
2
2
  module ConnectionAdapters
3
3
  module CockroachDB
4
4
  module Quoting
5
- private
6
-
7
5
  # CockroachDB does not allow inserting integer values into string
8
6
  # columns, but ActiveRecord expects this to work. CockroachDB will
9
7
  # however allow inserting string values into integer columns. It will
@@ -19,7 +17,7 @@ module ActiveRecord
19
17
  # (https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary)
20
18
  # but when creating objects, using RGeo features is more convenient than
21
19
  # converting to WKB, so this does it automatically.
22
- def _quote(value)
20
+ def quote(value)
23
21
  if value.is_a?(Numeric)
24
22
  "'#{quote_string(value.to_s)}'"
25
23
  elsif RGeo::Feature::Geometry.check_type(value)
@@ -20,17 +20,31 @@ module ActiveRecord
20
20
 
21
21
  yield
22
22
 
23
- foreign_keys.each do |foreign_key|
24
- begin
25
- add_foreign_key(foreign_key.from_table, foreign_key.to_table, **foreign_key.options)
26
- rescue ActiveRecord::StatementInvalid => error
27
- if error.cause.class == PG::DuplicateObject
28
- # This error is safe to ignore because the yielded caller
29
- # already re-added the foreign key constraint.
30
- else
31
- raise error
23
+ # Prefixes and suffixes are added in add_foreign_key
24
+ # in AR7+ so we need to temporarily disable them here,
25
+ # otherwise prefixes/suffixes will be erroneously added.
26
+ old_prefix = ActiveRecord::Base.table_name_prefix
27
+ old_suffix = ActiveRecord::Base.table_name_suffix
28
+
29
+ ActiveRecord::Base.table_name_prefix = ""
30
+ ActiveRecord::Base.table_name_suffix = ""
31
+
32
+ begin
33
+ foreign_keys.each do |foreign_key|
34
+ begin
35
+ add_foreign_key(foreign_key.from_table, foreign_key.to_table, **foreign_key.options)
36
+ rescue ActiveRecord::StatementInvalid => error
37
+ if error.cause.class == PG::DuplicateObject
38
+ # This error is safe to ignore because the yielded caller
39
+ # already re-added the foreign key constraint.
40
+ else
41
+ raise error
42
+ end
32
43
  end
33
44
  end
45
+ ensure
46
+ ActiveRecord::Base.table_name_prefix = old_prefix
47
+ ActiveRecord::Base.table_name_suffix = old_suffix
34
48
  end
35
49
  end
36
50
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module CockroachDB
6
+ class SchemaCreation < PostgreSQL::SchemaCreation # :nodoc:
7
+ private
8
+ def add_column_options!(sql, options)
9
+ if options[:hidden]
10
+ sql << " NOT VISIBLE"
11
+ end
12
+ super
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ module CockroachDB
6
+ class SchemaDumper < ConnectionAdapters::PostgreSQL::SchemaDumper # :nodoc:
7
+ private
8
+ def prepare_column_options(column)
9
+ spec = super
10
+ if column.hidden?
11
+ spec[:hidden] = true
12
+ end
13
+ spec
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -77,7 +77,7 @@ module ActiveRecord
77
77
  # override
78
78
  # https://github.com/rails/rails/blob/6-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L624
79
79
  def new_column_from_field(table_name, field)
80
- column_name, type, default, notnull, oid, fmod, collation, comment = field
80
+ column_name, type, default, notnull, oid, fmod, collation, comment, generated, hidden = field
81
81
  type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
82
82
  default_value = extract_value_from_default(default)
83
83
  default_function = extract_default_function(default_value, default)
@@ -99,7 +99,9 @@ module ActiveRecord
99
99
  collation: collation,
100
100
  comment: comment.presence,
101
101
  serial: serial,
102
- spatial: spatial
102
+ spatial: spatial,
103
+ generated: generated,
104
+ hidden: hidden
103
105
  )
104
106
  end
105
107
 
@@ -186,6 +188,14 @@ module ActiveRecord
186
188
  @spatial_column_info ||= {}
187
189
  @spatial_column_info[table_name.to_sym] ||= SpatialColumnInfo.new(self, table_name.to_s)
188
190
  end
191
+
192
+ def create_schema_dumper(options)
193
+ CockroachDB::SchemaDumper.create(self, options)
194
+ end
195
+
196
+ def schema_creation
197
+ CockroachDB::SchemaCreation.new(self)
198
+ end
189
199
  end
190
200
  end
191
201
  end
@@ -1,7 +1,10 @@
1
1
  require "rgeo/active_record"
2
2
 
3
3
  require "active_record/connection_adapters/postgresql_adapter"
4
+ require "active_record/connection_adapters/cockroachdb/attribute_methods"
4
5
  require "active_record/connection_adapters/cockroachdb/column_methods"
6
+ require "active_record/connection_adapters/cockroachdb/schema_creation"
7
+ require "active_record/connection_adapters/cockroachdb/schema_dumper"
5
8
  require "active_record/connection_adapters/cockroachdb/schema_statements"
6
9
  require "active_record/connection_adapters/cockroachdb/referential_integrity"
7
10
  require "active_record/connection_adapters/cockroachdb/transaction_manager"
@@ -9,14 +12,15 @@ require "active_record/connection_adapters/cockroachdb/database_statements"
9
12
  require "active_record/connection_adapters/cockroachdb/table_definition"
10
13
  require "active_record/connection_adapters/cockroachdb/quoting"
11
14
  require "active_record/connection_adapters/cockroachdb/type"
12
- require "active_record/connection_adapters/cockroachdb/attribute_methods"
13
15
  require "active_record/connection_adapters/cockroachdb/column"
14
16
  require "active_record/connection_adapters/cockroachdb/spatial_column_info"
15
17
  require "active_record/connection_adapters/cockroachdb/setup"
16
18
  require "active_record/connection_adapters/cockroachdb/oid/type_map_initializer"
17
19
  require "active_record/connection_adapters/cockroachdb/oid/spatial"
18
20
  require "active_record/connection_adapters/cockroachdb/oid/interval"
21
+ require "active_record/connection_adapters/cockroachdb/oid/date_time"
19
22
  require "active_record/connection_adapters/cockroachdb/arel_tosql"
23
+ require_relative "../migration/cockroachdb/compatibility"
20
24
  require_relative "../../version"
21
25
 
22
26
  # Run to ignore spatial tables that will break schemna dumper.
@@ -179,7 +183,10 @@ module ActiveRecord
179
183
  end
180
184
 
181
185
  def supports_expression_index?
182
- @crdb_version >= 2122
186
+ # Expression indexes are partially supported by CockroachDB v21.2,
187
+ # but activerecord requires "ON CONFLICT expression" support.
188
+ # See https://github.com/cockroachdb/cockroach/issues/67893
189
+ false
183
190
  end
184
191
 
185
192
  def supports_datetime_with_precision?
@@ -199,7 +206,7 @@ module ActiveRecord
199
206
  end
200
207
 
201
208
  def supports_virtual_columns?
202
- false
209
+ @crdb_version >= 2110
203
210
  end
204
211
 
205
212
  def supports_string_to_array_coercion?
@@ -210,6 +217,10 @@ module ActiveRecord
210
217
  false
211
218
  end
212
219
 
220
+ def supports_deferrable_constraints?
221
+ false
222
+ end
223
+
213
224
  # This is hardcoded to 63 (as previously was in ActiveRecord 5.0) to aid in
214
225
  # migration from PostgreSQL to CockroachDB. In practice, this limitation
215
226
  # is arbitrary since CockroachDB supports index name lengths and table alias
@@ -288,8 +299,20 @@ module ActiveRecord
288
299
  false
289
300
  end
290
301
 
291
- private
302
+ # override
303
+ # The PostgreSQLAdapter uses syntax for an anonymous function
304
+ # (DO $$) that CockroachDB does not support.
305
+ #
306
+ # Given a name and an array of values, creates an enum type.
307
+ def create_enum(name, values)
308
+ sql_values = values.map { |s| "'#{s}'" }.join(", ")
309
+ query = <<~SQL
310
+ CREATE TYPE IF NOT EXISTS \"#{name}\" AS ENUM (#{sql_values});
311
+ SQL
312
+ exec_query(query)
313
+ end
292
314
 
315
+ class << self
293
316
  def initialize_type_map(m = type_map)
294
317
  %w(
295
318
  geography
@@ -336,10 +359,13 @@ module ActiveRecord
336
359
  # lookups on PG
337
360
  Type::DecimalWithoutScale.new(precision: precision)
338
361
  else
339
- OID::Decimal.new(precision: precision, scale: scale)
362
+ ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Decimal.new(precision: precision, scale: scale)
340
363
  end
341
364
  end
342
365
  end
366
+ end
367
+
368
+ private
343
369
 
344
370
  # Configures the encoding, verbosity, schema search path, and time zone of the connection.
345
371
  # This is called by #connect and should not be called manually.
@@ -361,7 +387,7 @@ module ActiveRecord
361
387
  # If using Active Record's time zone support configure the connection to return
362
388
  # TIMESTAMP WITH ZONE types in UTC.
363
389
  unless variables["timezone"]
364
- if ActiveRecord::Base.default_timezone == :utc
390
+ if ActiveRecord.default_timezone == :utc
365
391
  variables["timezone"] = "UTC"
366
392
  elsif @local_tz
367
393
  variables["timezone"] = @local_tz
@@ -474,7 +500,8 @@ module ActiveRecord
474
500
  SELECT a.attname, format_type(a.atttypid, a.atttypmod),
475
501
  pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
476
502
  c.collname, NULL AS comment,
477
- #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated
503
+ #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,
504
+ NULL as is_hidden
478
505
  FROM pg_attribute a
479
506
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
480
507
  LEFT JOIN pg_type t ON a.atttypid = t.oid
@@ -500,8 +527,18 @@ module ActiveRecord
500
527
  dtype = field[1]
501
528
  field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)
502
529
  field[7] = crdb_fields[field[0]][1]&.gsub!(/^\'|\'?$/, '')
530
+ field[9] = true if crdb_fields[field[0]][3]
503
531
  field
504
532
  end
533
+ fields.delete_if do |field|
534
+ # Don't include rowid column if it is hidden and the primary key
535
+ # is not defined (meaning CRDB implicitly created it).
536
+ if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY
537
+ field[9] && !primary_key(table_name)
538
+ else
539
+ false # Keep this entry.
540
+ end
541
+ end
505
542
  end
506
543
 
507
544
  # Fetch the column comment because it's faster this way
@@ -512,7 +549,7 @@ module ActiveRecord
512
549
  def crdb_column_definitions(table_name)
513
550
  fields = \
514
551
  query(<<~SQL, "SCHEMA")
515
- SELECT c.column_name, c.column_comment, c.crdb_sql_type
552
+ SELECT c.column_name, c.column_comment, c.crdb_sql_type, c.is_hidden::BOOLEAN
516
553
  FROM information_schema.columns c
517
554
  WHERE c.table_name = #{quote(table_name)}
518
555
  SQL
@@ -0,0 +1,28 @@
1
+ require "active_record/migration"
2
+ require "active_record/migration/compatibility"
3
+
4
+ module ActiveRecord
5
+ class Migration
6
+ module CockroachDB
7
+ module Compatibility
8
+ module V7_0Patch
9
+ # Override. Use "CockroachDB" instead of "PostgreSQL"
10
+ def compatible_timestamp_type(type, connection)
11
+ if connection.adapter_name == "CockroachDB"
12
+ # For Rails <= 6.1, :datetime was aliased to :timestamp
13
+ # See: https://github.com/rails/rails/blob/v6.1.3.2/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L108
14
+ # From Rails 7 onwards, you can define what :datetime resolves to (the default is still :timestamp)
15
+ # See `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.datetime_type`
16
+ type.to_sym == :datetime ? :timestamp : type
17
+ else
18
+ type
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ prepend_mod = ActiveRecord::Migration::CockroachDB::Compatibility::V7_0Patch
28
+ ActiveRecord::Migration::Compatibility::V6_1::PostgreSQLCompat.singleton_class.prepend(prepend_mod)
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.8"
4
+ COCKROACH_DB_ADAPTER_VERSION = "7.0.0"
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.8
4
+ version: 7.0.0
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-03-14 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.1'
19
+ version: 7.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '6.1'
26
+ version: 7.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 7.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: benchmark-ips
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.9.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.9.1
55
69
  description: Allows the use of CockroachDB as a backend for ActiveRecord and Rails
56
70
  apps.
57
71
  email:
@@ -82,11 +96,14 @@ files:
82
96
  - lib/active_record/connection_adapters/cockroachdb/column_methods.rb
83
97
  - lib/active_record/connection_adapters/cockroachdb/database_statements.rb
84
98
  - lib/active_record/connection_adapters/cockroachdb/database_tasks.rb
99
+ - lib/active_record/connection_adapters/cockroachdb/oid/date_time.rb
85
100
  - lib/active_record/connection_adapters/cockroachdb/oid/interval.rb
86
101
  - lib/active_record/connection_adapters/cockroachdb/oid/spatial.rb
87
102
  - lib/active_record/connection_adapters/cockroachdb/oid/type_map_initializer.rb
88
103
  - lib/active_record/connection_adapters/cockroachdb/quoting.rb
89
104
  - lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb
105
+ - lib/active_record/connection_adapters/cockroachdb/schema_creation.rb
106
+ - lib/active_record/connection_adapters/cockroachdb/schema_dumper.rb
90
107
  - lib/active_record/connection_adapters/cockroachdb/schema_statements.rb
91
108
  - lib/active_record/connection_adapters/cockroachdb/setup.rb
92
109
  - lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb
@@ -94,6 +111,7 @@ files:
94
111
  - lib/active_record/connection_adapters/cockroachdb/transaction_manager.rb
95
112
  - lib/active_record/connection_adapters/cockroachdb/type.rb
96
113
  - lib/active_record/connection_adapters/cockroachdb_adapter.rb
114
+ - lib/active_record/migration/cockroachdb/compatibility.rb
97
115
  - lib/activerecord-cockroachdb-adapter.rb
98
116
  - lib/version.rb
99
117
  homepage: https://github.com/cockroachdb/activerecord-cockroachdb-adapter