activerecord-cockroachdb-adapter 7.1.0 → 7.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +22 -29
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +11 -2
  5. data/CONTRIBUTING.md +35 -90
  6. data/Gemfile +8 -4
  7. data/LICENSE +1 -2
  8. data/README.md +7 -5
  9. data/activerecord-cockroachdb-adapter.gemspec +2 -2
  10. data/bin/console +2 -2
  11. data/bin/start-cockroachdb +5 -20
  12. data/lib/active_record/connection_adapters/cockroachdb/arel_tosql.rb +14 -0
  13. data/lib/active_record/connection_adapters/cockroachdb/attribute_methods.rb +16 -0
  14. data/lib/active_record/connection_adapters/cockroachdb/column.rb +16 -0
  15. data/lib/active_record/connection_adapters/cockroachdb/column_methods.rb +14 -0
  16. data/lib/active_record/connection_adapters/cockroachdb/database_statements.rb +16 -0
  17. data/lib/active_record/connection_adapters/cockroachdb/database_tasks.rb +20 -3
  18. data/lib/active_record/connection_adapters/cockroachdb/oid/date_time.rb +14 -0
  19. data/lib/active_record/connection_adapters/cockroachdb/oid/interval.rb +16 -0
  20. data/lib/active_record/connection_adapters/cockroachdb/oid/spatial.rb +14 -0
  21. data/lib/active_record/connection_adapters/cockroachdb/quoting.rb +16 -0
  22. data/lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb +14 -0
  23. data/lib/active_record/connection_adapters/cockroachdb/schema_creation.rb +14 -1
  24. data/lib/active_record/connection_adapters/cockroachdb/schema_dumper.rb +14 -1
  25. data/lib/active_record/connection_adapters/cockroachdb/schema_statements.rb +102 -1
  26. data/lib/active_record/connection_adapters/cockroachdb/setup.rb +14 -0
  27. data/lib/active_record/connection_adapters/cockroachdb/spatial_column_info.rb +16 -0
  28. data/lib/active_record/connection_adapters/cockroachdb/table_definition.rb +14 -0
  29. data/lib/active_record/connection_adapters/cockroachdb/transaction_manager.rb +14 -0
  30. data/lib/active_record/connection_adapters/cockroachdb/type.rb +16 -0
  31. data/lib/active_record/connection_adapters/cockroachdb_adapter.rb +72 -126
  32. data/lib/active_record/migration/cockroachdb/compatibility.rb +16 -0
  33. data/lib/active_record/relation/query_methods_ext.rb +16 -3
  34. data/lib/activerecord-cockroachdb-adapter.rb +21 -0
  35. data/lib/arel/nodes/join_source_ext.rb +16 -0
  36. data/lib/version.rb +15 -1
  37. data/setup.sql +18 -0
  38. metadata +11 -12
  39. data/.ruby-version +0 -1
  40. data/lib/active_record/connection_adapters/cockroachdb/oid/type_map_initializer.rb +0 -26
@@ -1,3 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 The Cockroach Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
1
17
  if defined?(Rails::Railtie)
2
18
  module ActiveRecord
3
19
  module ConnectionAdapters
@@ -9,3 +25,8 @@ if defined?(Rails::Railtie)
9
25
  end
10
26
  end
11
27
  end
28
+
29
+ require "active_record"
30
+ require "active_record/connection_adapters"
31
+
32
+ ActiveRecord::ConnectionAdapters.register "cockroachdb", "ActiveRecord::ConnectionAdapters::CockroachDBAdapter", "active_record/connection_adapters/cockroachdb_adapter"
@@ -1,3 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 The Cockroach Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
1
17
  module Arel
2
18
  module Nodes
3
19
  module JoinSourceExt
data/lib/version.rb CHANGED
@@ -1,5 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Copyright 2024 The Cockroach Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  module ActiveRecord
4
- COCKROACH_DB_ADAPTER_VERSION = "7.1.0"
18
+ COCKROACH_DB_ADAPTER_VERSION = "7.2.0"
5
19
  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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cockroach Labs
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 7.1.0
19
+ version: 7.2.0
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: 7.1.0
26
+ version: 7.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: '1.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rgeo-activerecord
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +79,6 @@ files:
79
79
  - ".github/workflows/docker.yml"
80
80
  - ".gitignore"
81
81
  - ".gitmodules"
82
- - ".ruby-version"
83
82
  - CHANGELOG.md
84
83
  - CONTRIBUTING.md
85
84
  - Gemfile
@@ -106,7 +105,6 @@ files:
106
105
  - lib/active_record/connection_adapters/cockroachdb/oid/date_time.rb
107
106
  - lib/active_record/connection_adapters/cockroachdb/oid/interval.rb
108
107
  - lib/active_record/connection_adapters/cockroachdb/oid/spatial.rb
109
- - lib/active_record/connection_adapters/cockroachdb/oid/type_map_initializer.rb
110
108
  - lib/active_record/connection_adapters/cockroachdb/quoting.rb
111
109
  - lib/active_record/connection_adapters/cockroachdb/referential_integrity.rb
112
110
  - lib/active_record/connection_adapters/cockroachdb/schema_creation.rb
@@ -123,12 +121,13 @@ files:
123
121
  - lib/activerecord-cockroachdb-adapter.rb
124
122
  - lib/arel/nodes/join_source_ext.rb
125
123
  - lib/version.rb
124
+ - setup.sql
126
125
  homepage: https://github.com/cockroachdb/activerecord-cockroachdb-adapter
127
126
  licenses:
128
127
  - Apache-2.0
129
128
  metadata:
130
129
  allowed_push_host: https://rubygems.org
131
- post_install_message:
130
+ post_install_message:
132
131
  rdoc_options: []
133
132
  require_paths:
134
133
  - lib
@@ -143,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
142
  - !ruby/object:Gem::Version
144
143
  version: '0'
145
144
  requirements: []
146
- rubygems_version: 3.4.10
147
- signing_key:
145
+ rubygems_version: 3.0.3.1
146
+ signing_key:
148
147
  specification_version: 4
149
148
  summary: CockroachDB adapter for ActiveRecord.
150
149
  test_files: []
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.2.1
@@ -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