activerecord-cockroachdb-adapter 5.2.0 → 5.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2292eb1fe9b5352ccb2a135ee1681b342403f086d38d5c78f354d97008097fe
|
4
|
+
data.tar.gz: 7b144a460690d0a6eab7d827eb1e297c67f94be4191d8c949f33d74e90050a88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6424288bb2dce9c2a530f3d2b0edd303c156fdd8dd85822756f9953ca7ebaff4cc32fed8cc233c580e570f561797d38ca741837edeccf5c4e95639b7e2dab816
|
7
|
+
data.tar.gz: 0d69e3fbf8e5809429608bbd292269affc21d88afcd7687a26443e6bbb55754bd623ba4d62da484a1ad4415f6633ba9f49eb57ba1e7d54ba632d3fc30e922eaa
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ CockroachDB adapter for ActiveRecord 4 and 5. This is a lightweight extension of
|
|
7
7
|
Add this line to your project's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'activerecord-cockroachdb-adapter', '~>
|
10
|
+
gem 'activerecord-cockroachdb-adapter', '~> 5.2.0'
|
11
11
|
```
|
12
12
|
|
13
13
|
If you're using Rails 4.x, use the `0.1.x` versions of this gem.
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "activerecord-cockroachdb-adapter"
|
7
|
-
spec.version = "5.2.
|
7
|
+
spec.version = "5.2.1"
|
8
8
|
spec.licenses = ["Apache-2.0"]
|
9
9
|
spec.authors = ["Cockroach Labs"]
|
10
10
|
spec.email = ["cockroach-db@googlegroups.com"]
|
data/build/teamcity-test.sh
CHANGED
@@ -83,8 +83,7 @@ module ActiveRecord
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def supports_partial_index?
|
86
|
-
|
87
|
-
false
|
86
|
+
@crdb_version >= 202
|
88
87
|
end
|
89
88
|
|
90
89
|
def supports_expression_index?
|
@@ -115,6 +114,10 @@ module ActiveRecord
|
|
115
114
|
false
|
116
115
|
end
|
117
116
|
|
117
|
+
def supports_string_to_array_coercion?
|
118
|
+
@crdb_version >= 202
|
119
|
+
end
|
120
|
+
|
118
121
|
# This is hardcoded to 63 (as previously was in ActiveRecord 5.0) to aid in
|
119
122
|
# migration from PostgreSQL to CockroachDB. In practice, this limitation
|
120
123
|
# is arbitrary since CockroachDB supports index name lengths and table alias
|
@@ -130,6 +133,25 @@ module ActiveRecord
|
|
130
133
|
alias index_name_length max_identifier_length
|
131
134
|
alias table_alias_length max_identifier_length
|
132
135
|
|
136
|
+
def initialize(connection, logger, conn_params, config)
|
137
|
+
super(connection, logger, conn_params, config)
|
138
|
+
crdb_version_string = query_value("SHOW crdb_version")
|
139
|
+
if crdb_version_string.include? "v1."
|
140
|
+
version_num = 1
|
141
|
+
elsif crdb_version_string.include? "v2."
|
142
|
+
version_num 2
|
143
|
+
elsif crdb_version_string.include? "v19.1."
|
144
|
+
version_num = 191
|
145
|
+
elsif crdb_version_string.include? "v19.2."
|
146
|
+
version_num = 192
|
147
|
+
elsif crdb_version_string.include? "v20.1."
|
148
|
+
version_num = 201
|
149
|
+
else
|
150
|
+
version_num = 202
|
151
|
+
end
|
152
|
+
@crdb_version = version_num
|
153
|
+
end
|
154
|
+
|
133
155
|
private
|
134
156
|
|
135
157
|
def initialize_type_map(m = type_map)
|
@@ -202,7 +224,8 @@ module ActiveRecord
|
|
202
224
|
def extract_value_from_default(default)
|
203
225
|
super ||
|
204
226
|
extract_escaped_string_from_default(default) ||
|
205
|
-
extract_time_from_default(default)
|
227
|
+
extract_time_from_default(default) ||
|
228
|
+
extract_empty_array_from_default(default)
|
206
229
|
end
|
207
230
|
|
208
231
|
# Both PostgreSQL and CockroachDB use C-style string escapes under the
|
@@ -244,6 +267,15 @@ module ActiveRecord
|
|
244
267
|
nil
|
245
268
|
end
|
246
269
|
|
270
|
+
# CockroachDB stores default values for arrays in the `ARRAY[...]` format.
|
271
|
+
# In general, it is hard to parse that, but it is easy to handle the common
|
272
|
+
# case of an empty array.
|
273
|
+
def extract_empty_array_from_default(default)
|
274
|
+
return unless supports_string_to_array_coercion?
|
275
|
+
return unless default =~ /\AARRAY\[\]\z/
|
276
|
+
return "{}"
|
277
|
+
end
|
278
|
+
|
247
279
|
# end private
|
248
280
|
end
|
249
281
|
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: 5.2.
|
4
|
+
version: 5.2.1
|
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: 2020-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -77,7 +77,7 @@ licenses:
|
|
77
77
|
- Apache-2.0
|
78
78
|
metadata:
|
79
79
|
allowed_push_host: https://rubygems.org
|
80
|
-
post_install_message:
|
80
|
+
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
@@ -92,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.1.
|
96
|
-
signing_key:
|
95
|
+
rubygems_version: 3.1.4
|
96
|
+
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: CockroachDB adapter for ActiveRecord.
|
99
99
|
test_files: []
|