activerecord-pg-extensions 0.2.0 → 0.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: 5c618a82f7b01b308540312e68b6764d975cb6e9594d619996a5ce7502a0b72c
|
4
|
+
data.tar.gz: d5b9179b9b7d2761c360092e1ff9e1c8ce27f6f49c39cb7e0e9a4f1b0d7ed97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edf57be20052135e65634cb992948ce612a4a5d107d6fc5e8e3de50a420cc7de8afe61a4311981a2e4684060f25ee9ceb97a6997ee22cb80c09ea6c94b2dda24
|
7
|
+
data.tar.gz: ad6a7c3da37ed59d2a110d25217e2e7dba90fec35b448f3446d91a43874c86c32eb7672f783acb0e69561d9353b950df75e78d683800b594c1d1a0193f16a9c8
|
data/CHANGELOG.md
CHANGED
@@ -235,6 +235,51 @@ module ActiveRecord
|
|
235
235
|
|
236
236
|
private
|
237
237
|
|
238
|
+
if ::Rails.version < "6.1"
|
239
|
+
# significant change: add PG::TextDecoder::Numeric
|
240
|
+
def add_pg_decoders
|
241
|
+
@default_timezone = nil
|
242
|
+
@timestamp_decoder = nil
|
243
|
+
|
244
|
+
coders_by_name = {
|
245
|
+
"int2" => PG::TextDecoder::Integer,
|
246
|
+
"int4" => PG::TextDecoder::Integer,
|
247
|
+
"int8" => PG::TextDecoder::Integer,
|
248
|
+
"oid" => PG::TextDecoder::Integer,
|
249
|
+
"float4" => PG::TextDecoder::Float,
|
250
|
+
"float8" => PG::TextDecoder::Float,
|
251
|
+
"bool" => PG::TextDecoder::Boolean,
|
252
|
+
"numeric" => PG::TextDecoder::Numeric
|
253
|
+
}
|
254
|
+
|
255
|
+
if defined?(PG::TextDecoder::TimestampUtc)
|
256
|
+
# Use native PG encoders available since pg-1.1
|
257
|
+
coders_by_name["timestamp"] = PG::TextDecoder::TimestampUtc
|
258
|
+
coders_by_name["timestamptz"] = PG::TextDecoder::TimestampWithTimeZone
|
259
|
+
end
|
260
|
+
|
261
|
+
known_coder_types = coders_by_name.keys.map { |n| quote(n) }
|
262
|
+
query = <<~SQL.format(known_coder_types.join(", "))
|
263
|
+
SELECT t.oid, t.typname
|
264
|
+
FROM pg_type as t
|
265
|
+
WHERE t.typname IN (%s)
|
266
|
+
SQL
|
267
|
+
coders = execute_and_clear(query, "SCHEMA", []) do |result|
|
268
|
+
result
|
269
|
+
.map { |row| construct_coder(row, coders_by_name[row["typname"]]) }
|
270
|
+
.compact
|
271
|
+
end
|
272
|
+
|
273
|
+
map = PG::TypeMapByOid.new
|
274
|
+
coders.each { |coder| map.add_coder(coder) }
|
275
|
+
@connection.type_map_for_results = map
|
276
|
+
|
277
|
+
# extract timestamp decoder for use in update_typemap_for_default_timezone
|
278
|
+
@timestamp_decoder = coders.find { |coder| coder.name == "timestamp" }
|
279
|
+
update_typemap_for_default_timezone
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
238
283
|
def initialize_type_map(map = type_map)
|
239
284
|
map.register_type "pg_lsn", ActiveRecord::ConnectionAdapters::PostgreSQL::OID::SpecializedString.new(:pg_lsn)
|
240
285
|
|
@@ -243,5 +243,11 @@ describe ActiveRecord::ConnectionAdapters::PostgreSQLAdapter do
|
|
243
243
|
expect(connection.in_recovery?).to eq false
|
244
244
|
end
|
245
245
|
end
|
246
|
+
|
247
|
+
describe "#select_value" do
|
248
|
+
it "has casts numeric types" do
|
249
|
+
expect(connection.select_value("SELECT factorial(2)")).to eq 2
|
250
|
+
end
|
251
|
+
end
|
246
252
|
end
|
247
253
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-pg-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|