activerecord-cockroachdb-adapter 7.1.0 → 7.1.1

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: 6c3f85e82470685a2ece6851d557bcaf03f5a77ce309d76062c3960ca17d1606
4
- data.tar.gz: b6ab7bfb9d29feebf217b70b11ccf2f73e6fb0853138cc27f4556f07b6c36dac
3
+ metadata.gz: 672289521537934d4b9ed2d707c3faf55b4761c8d2b4e9e12cd8622166963ae7
4
+ data.tar.gz: 345a84d7c5bca0d574aa65eb0fb0e30986a23fcc2830f422e5b1d80ffa971076
5
5
  SHA512:
6
- metadata.gz: 96fbb4c5a42c1ab3f2fe590f3c74012b883c818608c5b9d0525f30739f1d4d8733c95cfffd31a8a05350d6210d995f84d915727a494264d1cb1c217d10d200b1
7
- data.tar.gz: 12ae86ab8f26eb074eabb60cd3f831eed44729d98f70bdc88d1c0d9c3d5cff5680ae7cf0a9643756395e6cfc1257cb7fc62ee5abab4c37c6f0fe45817fc619a0
6
+ metadata.gz: 4ce6d2119bfc27192630c32ec488b3e7f533cc64963fc04035609122e5bdbc33e75b83766ca68e3eb73e2592b2fe0a1bae53a74389527762f790b16bda687da9
7
+ data.tar.gz: 42e10ab1106e4ffc4df89bbbf98f8ddbd05b6bccf97b062a9445ebf874a8bfef9e628dce8b39c3287424a7094f70790457293a2766a849bd39ac0e20c7a684fe
@@ -37,15 +37,17 @@ jobs:
37
37
  test:
38
38
  runs-on: ubuntu-latest
39
39
  strategy:
40
+ fail-fast: false
40
41
  matrix:
41
- crdb: [v23.1.11]
42
+ # https://www.cockroachlabs.com/docs/releases/release-support-policy
43
+ crdb: [v22.2, v23.1, v23.2]
42
44
  ruby: [head]
43
45
  name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }})
44
46
  steps:
45
47
  - name: Set Up Actions
46
48
  uses: actions/checkout@v4
47
49
  - name: Install GEOS
48
- run: sudo apt-get install libgeos-dev
50
+ run: sudo apt-get install -yqq libgeos-dev
49
51
  - name: Set Up Ruby
50
52
  uses: ruby/setup-ruby@v1
51
53
  with:
@@ -54,16 +56,28 @@ jobs:
54
56
  - name: Install and Start Cockroachdb
55
57
  run: |
56
58
  # Download CockroachDB
57
- wget -qO- https://binaries.cockroachdb.com/cockroach-${{ matrix.crdb }}.linux-amd64.tgz | tar xvz
59
+ readonly full_version=$(ruby -rnet/http -ruri -ryaml -e '
60
+ link = "https://raw.githubusercontent.com/cockroachdb/docs/main/src/current/_data/releases.yml"
61
+ puts YAML.safe_load(Net::HTTP.get(URI(link))).reverse.find {
62
+ _1["major_version"] == "${{ matrix.crdb }}" &&
63
+ _1["release_type"] == "Production" &&
64
+ !_1["cloud_only"] &&
65
+ !_1["withdrawn"] &&
66
+ !_1["release_name"].include?("-") # Pre-release
67
+ }["release_name"]
68
+ ')
58
69
 
59
- export PATH=./cockroach-${{ matrix.crdb }}.linux-amd64/:$PATH
70
+ echo "Downloading $full_version..."
71
+ wget -qO- "https://binaries.cockroachdb.com/cockroach-$full_version.linux-amd64.tgz" | tar xvz
72
+
73
+ export PATH=./cockroach-$full_version.linux-amd64/:$PATH
60
74
  readonly urlfile=cockroach-url
61
75
 
62
76
  # Start a CockroachDB server and wait for it to become ready.
63
77
  rm -f "$urlfile"
64
78
  rm -rf cockroach-data
65
79
  # Start CockroachDB.
66
- cockroach start-single-node --max-sql-memory=25% --cache=25% --insecure --host=localhost --spatial-libs=./cockroach-${{ matrix.crdb }}.linux-amd64/lib --listening-url-file="$urlfile" >/dev/null 2>&1 &
80
+ cockroach start-single-node --max-sql-memory=25% --cache=25% --insecure --host=localhost --spatial-libs=./cockroach-$full_version.linux-amd64/lib --listening-url-file="$urlfile" >/dev/null 2>&1 &
67
81
  # Ensure CockroachDB is stopped on script exit.
68
82
  # Wait until CockroachDB has started.
69
83
  for i in {0..3}; do
@@ -72,27 +86,6 @@ jobs:
72
86
  echo "server not yet available; sleeping for $backoff seconds"
73
87
  sleep $backoff
74
88
  done
75
- cockroach sql --insecure -e "
76
- CREATE DATABASE activerecord_unittest;
77
- CREATE DATABASE activerecord_unittest2;
78
- SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
79
- SET CLUSTER SETTING sql.stats.histogram_collection.enabled = false;
80
- SET CLUSTER SETTING jobs.retention_time = '180s';
81
- SET CLUSTER SETTING sql.defaults.experimental_alter_column_type.enabled = 'true';
82
-
83
- ALTER RANGE default CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;
84
- ALTER TABLE system.public.jobs CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;
85
- ALTER RANGE meta CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;
86
- ALTER RANGE system CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;
87
- ALTER RANGE liveness CONFIGURE ZONE USING num_replicas = 1, gc.ttlseconds = 30;
88
-
89
- SET CLUSTER SETTING kv.range_merge.queue_interval = '50ms';
90
- SET CLUSTER SETTING kv.raft_log.disable_synchronization_unsafe = 'true';
91
- SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';
92
- SET CLUSTER SETTING jobs.registry.interval.gc = '30s';
93
- SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
94
-
95
- SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';
96
- "
89
+ cat ${{ github.workspace }}/setup.sql | cockroach sql --insecure
97
90
  - name: Test
98
91
  run: bundle exec rake test TESTOPTS='--profile=3'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.1
1
+ 3.2.3
data/CHANGELOG.md CHANGED
@@ -2,12 +2,17 @@
2
2
 
3
3
  ## Ongoing
4
4
 
5
- - Add support for [AOST](cockroachlabs.com/docs/stable/as-of-system-time) queries ([#284](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/284))
6
- - Dump schema name in foreign keys ([#289](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/289))
5
+ ## 7.1.1 - 2024-05-01
6
+
7
+ - Enable precision support ([#318](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/318))
8
+ - Support arbitrary max identifier length ([#317](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/317)).
9
+ - Fix `#schema_names` not to return `crdb_internal` ([#316](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/316))
7
10
 
8
11
  ## 7.1.0 - 2024-01-30
9
12
 
10
13
  - Add support for Rails 7.1 ([#300](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/300)).
14
+ - Add support for [AOST](cockroachlabs.com/docs/stable/as-of-system-time) queries ([#284](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/284))
15
+ - Dump schema name in foreign keys ([#289](https://github.com/cockroachdb/activerecord-cockroachdb-adapter/pull/289))
11
16
 
12
17
  ## 7.0.3 - 2023-08-23
13
18
 
data/Gemfile CHANGED
@@ -55,6 +55,10 @@ group :development, :test do
55
55
  gem "debug"
56
56
  gem "minitest-excludes", "~> 2.0.1"
57
57
  gem "minitest-github_action_reporter", github: "BuonOmo/minitest-github_action_reporter", require: "minitest/github_action_reporter_plugin"
58
+ gem "ostruct", "~> 0.6"
59
+
60
+ # Gems used for tests meta-programming.
61
+ gem "parser"
58
62
 
59
63
  # Gems used by the ActiveRecord test suite
60
64
  gem "bcrypt", "~> 3.1.18"
data/bin/console CHANGED
@@ -12,7 +12,7 @@ require "active_record"
12
12
  # structure_load(Post.connection_db_config, "awesome-file.sql")
13
13
  require "active_record/connection_adapters/cockroachdb/database_tasks"
14
14
 
15
- schema_kind = ENV.fetch("SCHEMA_KIND", "default")
15
+ schema_kind = ENV.fetch("SCHEMA_KIND", ENV.fetch("SCHEMA", "default"))
16
16
 
17
17
  system("cockroach sql --insecure --host=localhost:26257 --execute='drop database if exists ar_crdb_console'",
18
18
  exception: true)
@@ -9,7 +9,7 @@ pid_file="$root_dir/tmp/cockroach.pid"
9
9
  log_file="$root_dir/tmp/cockroachdb.log"
10
10
 
11
11
  mkdir -p "$root_dir/tmp"
12
- [[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file")
12
+ [[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file") || true
13
13
  rm -f "$pid_file"
14
14
 
15
15
  if ! (( ${+commands[cockroach]} )); then
@@ -18,7 +18,9 @@ See https://www.cockroachlabs.com/docs/stable/install-cockroachdb.html'
18
18
  fi
19
19
 
20
20
  cockroach start-single-node \
21
- --insecure --store=type=mem,size=0.25 --advertise-addr=localhost --pid-file "$pid_file" \
21
+ --insecure --store=type=mem,size=0.25 --advertise-addr=localhost \
22
+ --spatial-libs="$(geos-config --includes)" \
23
+ --pid-file "$pid_file" \
22
24
  &> "$log_file" &
23
25
 
24
26
  until [[ -f "$pid_file" ]]; do
@@ -26,23 +28,6 @@ until [[ -f "$pid_file" ]]; do
26
28
  done
27
29
 
28
30
 
29
- cat <<-SQL | cockroach sql --insecure --host=localhost:26257 > /dev/null
30
- -- https://www.cockroachlabs.com/docs/stable/local-testing.html
31
- SET CLUSTER SETTING kv.raft_log.disable_synchronization_unsafe = true;
32
- SET CLUSTER SETTING kv.range_merge.queue_interval = '50ms';
33
- SET CLUSTER SETTING jobs.registry.interval.gc = '30s';
34
- SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';
35
- SET CLUSTER SETTING jobs.retention_time = '15s';
36
- SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
37
- SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
38
- ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;
39
- ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;
40
-
41
- CREATE DATABASE activerecord_unittest;
42
- CREATE DATABASE activerecord_unittest2;
43
-
44
- SET CLUSTER SETTING sql.defaults.experimental_alter_column_type.enabled = 'true';
45
- SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';
46
- SQL
31
+ cat "$root_dir/setup.sql" | cockroach sql --insecure --host=localhost:26257 > /dev/null
47
32
 
48
33
  echo "CockroachDB started. PID: $(cat "$pid_file"). log: $log_file"
@@ -26,6 +26,7 @@ module ActiveRecord
26
26
  old_search_path = conn.schema_search_path
27
27
  conn.schema_search_path = search_path
28
28
  File.open(filename, "w") do |file|
29
+ # NOTE: There is no issue with the crdb_internal schema, it is ignored by SHOW CREATE.
29
30
  %w(SCHEMAS TYPES).each do |object_kind|
30
31
  ActiveRecord::Base.connection.execute("SHOW CREATE ALL #{object_kind}").each_row { file.puts _1 }
31
32
  end
@@ -44,7 +45,7 @@ module ActiveRecord
44
45
 
45
46
  file.puts sql
46
47
  end
47
- file.puts "SET seach_path TO #{conn.schema_search_path};\n\n"
48
+ file.puts "SET search_path TO #{conn.schema_search_path};\n\n"
48
49
  end
49
50
  ensure
50
51
  conn.schema_search_path = old_search_path
@@ -4,6 +4,13 @@ module ActiveRecord
4
4
  module SchemaStatements
5
5
  include ActiveRecord::ConnectionAdapters::PostgreSQL::SchemaStatements
6
6
 
7
+ # OVERRIDE: We do not want to see the crdb_internal schema in the names.
8
+ #
9
+ # Returns an array of schema names.
10
+ def schema_names
11
+ super - ["crdb_internal"]
12
+ end
13
+
7
14
  def add_index(table_name, column_name, **options)
8
15
  super
9
16
  rescue ActiveRecord::StatementInvalid => error
@@ -40,7 +47,7 @@ module ActiveRecord
40
47
  # so we append it manually.
41
48
  def foreign_keys(table_name)
42
49
  scope = quoted_scope(table_name)
43
- fk_info = exec_query(<<~SQL, "SCHEMA")
50
+ fk_info = internal_exec_query(<<~SQL, "SCHEMA")
44
51
  SELECT CASE
45
52
  WHEN n2.nspname = current_schema()
46
53
  THEN ''
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rgeo/active_record"
2
4
 
3
5
  require_relative "../../arel/nodes/join_source_ext"
@@ -16,7 +18,6 @@ require "active_record/connection_adapters/cockroachdb/type"
16
18
  require "active_record/connection_adapters/cockroachdb/column"
17
19
  require "active_record/connection_adapters/cockroachdb/spatial_column_info"
18
20
  require "active_record/connection_adapters/cockroachdb/setup"
19
- require "active_record/connection_adapters/cockroachdb/oid/type_map_initializer"
20
21
  require "active_record/connection_adapters/cockroachdb/oid/spatial"
21
22
  require "active_record/connection_adapters/cockroachdb/oid/interval"
22
23
  require "active_record/connection_adapters/cockroachdb/oid/date_time"
@@ -31,35 +32,15 @@ require_relative "../relation/query_methods_ext"
31
32
  ActiveRecord::ConnectionAdapters::CockroachDB.initial_setup
32
33
 
33
34
  module ActiveRecord
35
+ # TODO: once in rails 7.2, remove this and replace with a `#register` call.
36
+ # See: https://github.com/rails/rails/commit/22a26d7f74ea8f0d5f7c4169531ae38441cfd5e5#diff-2468c670eb10c24bd2823e42708489a336d6f21c6efc7e3c4a574166fa77bb22
34
37
  module ConnectionHandling
38
+ def cockroachdb_adapter_class
39
+ ConnectionAdapters::CockroachDBAdapter
40
+ end
41
+
35
42
  def cockroachdb_connection(config)
36
- # This is copied from the PostgreSQL adapter.
37
- conn_params = config.symbolize_keys.compact
38
-
39
- # Map ActiveRecords param names to PGs.
40
- conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
41
- conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
42
-
43
- # Forward only valid config params to PG::Connection.connect.
44
- valid_conn_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]
45
- conn_params.slice!(*valid_conn_param_keys)
46
-
47
- ConnectionAdapters::CockroachDBAdapter.new(
48
- ConnectionAdapters::CockroachDBAdapter.new_client(conn_params),
49
- logger,
50
- conn_params,
51
- config
52
- )
53
- # This rescue flow appears in new_client, but it is needed here as well
54
- # since Cockroach will sometimes not raise until a query is made.
55
- rescue ActiveRecord::StatementInvalid => error
56
- no_db_err_check1 = conn_params && conn_params[:dbname] && error.cause.message.include?(conn_params[:dbname])
57
- no_db_err_check2 = conn_params && conn_params[:dbname] && error.cause.message.include?("pg_type")
58
- if no_db_err_check1 || no_db_err_check2
59
- raise ActiveRecord::NoDatabaseError
60
- else
61
- raise ActiveRecord::ConnectionNotEstablished, error.message
62
- end
43
+ cockroachdb_adapter_class.new(config)
63
44
  end
64
45
  end
65
46
  end
@@ -101,7 +82,7 @@ module ActiveRecord
101
82
  ConnectionPool.prepend(CockroachDBConnectionPool)
102
83
 
103
84
  class CockroachDBAdapter < PostgreSQLAdapter
104
- ADAPTER_NAME = "CockroachDB".freeze
85
+ ADAPTER_NAME = "CockroachDB"
105
86
  DEFAULT_PRIMARY_KEY = "rowid"
106
87
 
107
88
  SPATIAL_COLUMN_OPTIONS =
@@ -155,18 +136,21 @@ module ActiveRecord
155
136
  @max_transaction_retries ||= @config.fetch(:max_transaction_retries, 3)
156
137
  end
157
138
 
158
- # CockroachDB 20.1 can run queries that work against PostgreSQL 10+.
159
- def postgresql_version
160
- 100000
139
+ def get_database_version
140
+ major, minor, patch = query_value("SHOW crdb_version").match(/v(\d+).(\d+).(\d+)/)[1..].map(&:to_i)
141
+ major * 100 * 100 + minor * 100 + patch
161
142
  end
143
+ undef :postgresql_version
144
+ alias :cockroachdb_version :database_version
162
145
 
163
- def supports_bulk_alter?
164
- true
146
+ def supports_datetime_with_precision?
147
+ # https://github.com/cockroachdb/cockroach/pull/111400
148
+ database_version >= 23_01_13
165
149
  end
166
150
 
167
- def supports_json?
168
- # FIXME(joey): Add a version check.
169
- true
151
+ def supports_nulls_not_distinct?
152
+ # https://github.com/cockroachdb/cockroach/issues/115836
153
+ false
170
154
  end
171
155
 
172
156
  def supports_ddl_transactions?
@@ -181,10 +165,6 @@ module ActiveRecord
181
165
  false
182
166
  end
183
167
 
184
- def supports_partial_index?
185
- true
186
- end
187
-
188
168
  def supports_index_include?
189
169
  false
190
170
  end
@@ -200,14 +180,6 @@ module ActiveRecord
200
180
  false
201
181
  end
202
182
 
203
- def supports_datetime_with_precision?
204
- false
205
- end
206
-
207
- def supports_comments?
208
- true
209
- end
210
-
211
183
  def supports_comments_in_create?
212
184
  false
213
185
  end
@@ -232,21 +204,6 @@ module ActiveRecord
232
204
  false
233
205
  end
234
206
 
235
- # This is hardcoded to 63 (as previously was in ActiveRecord 5.0) to aid in
236
- # migration from PostgreSQL to CockroachDB. In practice, this limitation
237
- # is arbitrary since CockroachDB supports index name lengths and table alias
238
- # lengths far greater than this value. For the time being though, we match
239
- # the original behavior for PostgreSQL to simplify migrations.
240
- #
241
- # Note that in the migration to ActiveRecord 5.1, this was changed in
242
- # PostgreSQLAdapter to use `SHOW max_identifier_length` (which does not
243
- # exist in CockroachDB). Therefore, we have to redefine this here.
244
- def max_identifier_length
245
- 63
246
- end
247
- alias index_name_length max_identifier_length
248
- alias table_alias_length max_identifier_length
249
-
250
207
  # NOTE: This commented bit of code allows to have access to crdb version,
251
208
  # which can be useful for feature detection. However, we currently don't
252
209
  # need, hence we avoid the extra queries.
@@ -278,6 +235,21 @@ module ActiveRecord
278
235
  false
279
236
  end
280
237
 
238
+ def initialize(...)
239
+ super
240
+
241
+ # This rescue flow appears in new_client, but it is needed here as well
242
+ # since Cockroach will sometimes not raise until a query is made.
243
+ rescue ActiveRecord::StatementInvalid => error
244
+ no_db_err_check1 = @connection_parameters && @connection_parameters[:dbname] && error.cause.message.include?(@connection_parameters[:dbname])
245
+ no_db_err_check2 = @connection_parameters && @connection_parameters[:dbname] && error.cause.message.include?("pg_type")
246
+ if no_db_err_check1 || no_db_err_check2
247
+ raise ActiveRecord::NoDatabaseError
248
+ else
249
+ raise ActiveRecord::ConnectionNotEstablished, error.message
250
+ end
251
+ end
252
+
281
253
  # override
282
254
  # The PostgreSQLAdapter uses syntax for an anonymous function
283
255
  # (DO $$) that CockroachDB does not support.
@@ -351,7 +323,6 @@ module ActiveRecord
351
323
  def extract_value_from_default(default)
352
324
  super ||
353
325
  extract_escaped_string_from_default(default) ||
354
- extract_time_from_default(default) ||
355
326
  extract_empty_array_from_default(default) ||
356
327
  extract_decimal_from_default(default)
357
328
  end
@@ -369,32 +340,6 @@ module ActiveRecord
369
340
  "\"#{$1}\"".undump.gsub("\\'".freeze, "'".freeze)
370
341
  end
371
342
 
372
- # This method exists to extract the correct time and date defaults for a
373
- # couple of reasons.
374
- # 1) There's a bug in CockroachDB where the date type is missing from
375
- # the column info query.
376
- # https://github.com/cockroachdb/cockroach/issues/47285
377
- # 2) PostgreSQL's timestamp without time zone type maps to CockroachDB's
378
- # TIMESTAMP type. TIMESTAMP includes a UTC time zone while timestamp
379
- # without time zone doesn't.
380
- # https://www.cockroachlabs.com/docs/v19.2/timestamp.html#variants
381
- def extract_time_from_default(default)
382
- return unless default =~ /\A'(.*)'\z/
383
-
384
- # If default has a UTC time zone, we'll drop the time zone information
385
- # so it acts like PostgreSQL's timestamp without time zone. Then, try
386
- # to parse the resulting string to verify if it's a time.
387
- time = if default =~ /\A'(.*)(\+00:00)'\z/
388
- $1
389
- else
390
- default
391
- end
392
-
393
- Time.parse(time).to_s
394
- rescue
395
- nil
396
- end
397
-
398
343
  # CockroachDB stores default values for arrays in the `ARRAY[...]` format.
399
344
  # In general, it is hard to parse that, but it is easy to handle the common
400
345
  # case of an empty array.
@@ -76,10 +76,9 @@ module ActiveRecord
76
76
  self
77
77
  end
78
78
 
79
- # TODO: reset or no reset?
80
-
81
79
  def show_create
82
- connection.execute("show create table #{connection.quote_table_name self.table_name}").first["create_statement"]
80
+ quoted_table = connection.quote_table_name self.table_name
81
+ connection.select_one("show create table #{quoted_table}")["create_statement"]
83
82
  end
84
83
 
85
84
  private
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 = "7.1.0"
4
+ COCKROACH_DB_ADAPTER_VERSION = "7.1.1"
5
5
  end
data/setup.sql ADDED
@@ -0,0 +1,18 @@
1
+ -- https://www.cockroachlabs.com/docs/stable/local-testing.html
2
+ SET CLUSTER SETTING kv.range_merge.queue_interval = '50ms';
3
+ SET CLUSTER SETTING jobs.registry.interval.gc = '30s';
4
+ SET CLUSTER SETTING jobs.registry.interval.cancel = '180s';
5
+ SET CLUSTER SETTING jobs.retention_time = '15s';
6
+ SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
7
+ SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
8
+ ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 600;
9
+ ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 600;
10
+
11
+ CREATE DATABASE activerecord_unittest;
12
+ CREATE DATABASE activerecord_unittest2;
13
+
14
+ SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
15
+ SET CLUSTER SETTING sql.stats.histogram_collection.enabled = false;
16
+
17
+ SET CLUSTER SETTING sql.defaults.experimental_alter_column_type.enabled = 'true';
18
+ SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';
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: 7.1.0
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cockroach Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -106,7 +106,6 @@ files:
106
106
  - lib/active_record/connection_adapters/cockroachdb/oid/date_time.rb
107
107
  - lib/active_record/connection_adapters/cockroachdb/oid/interval.rb
108
108
  - lib/active_record/connection_adapters/cockroachdb/oid/spatial.rb
109
- - lib/active_record/connection_adapters/cockroachdb/oid/type_map_initializer.rb
110
109
  - lib/active_record/connection_adapters/cockroachdb/quoting.rb
111
110
  - lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb
112
111
  - lib/active_record/connection_adapters/cockroachdb/schema_creation.rb
@@ -123,6 +122,7 @@ files:
123
122
  - lib/activerecord-cockroachdb-adapter.rb
124
123
  - lib/arel/nodes/join_source_ext.rb
125
124
  - lib/version.rb
125
+ - setup.sql
126
126
  homepage: https://github.com/cockroachdb/activerecord-cockroachdb-adapter
127
127
  licenses:
128
128
  - Apache-2.0
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.4.10
146
+ rubygems_version: 3.4.9
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: CockroachDB adapter for ActiveRecord.
@@ -1,26 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module CockroachDB
4
- module OID
5
- module TypeMapInitializer
6
- # override
7
- # Replaces the query with a faster version that doesn't rely on the
8
- # use of 'array_in(cstring,oid,integer)'::regprocedure.
9
- def query_conditions_for_initial_load
10
- known_type_names = @store.keys.map { |n| "'#{n}'" }
11
- known_type_types = %w('r' 'e' 'd')
12
- <<~SQL % [known_type_names.join(", "), known_type_types.join(", ")]
13
- WHERE
14
- t.typname IN (%s)
15
- OR t.typtype IN (%s)
16
- OR (t.typarray = 0 AND t.typcategory='A')
17
- OR t.typelem != 0
18
- SQL
19
- end
20
- end
21
-
22
- PostgreSQL::OID::TypeMapInitializer.prepend(TypeMapInitializer)
23
- end
24
- end
25
- end
26
- end