activerecord-cipherstash-pg-adapter 0.7.0 → 0.7.2
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 +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +6 -1
- data/activerecord-cipherstash-pg-adapter.gemspec +1 -1
- data/lib/active_record/connection_adapters/6.1/postgres_cipherstash_adapter.rb +33 -33
- data/lib/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9bf0b9639a218a5da0dde267803a200993b45d5a1da9893f24e09ec259f9035
|
4
|
+
data.tar.gz: c8e8a2fc36e7f7aedeea6e18f35726237bd4086c839c70536630d2f7c2938ee6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4778556b03aacc6573fe0c03d1c348d976ee0e8f03e1f3c6f5e514c8975f7a662c6cb522a531e482f6d3f74ca8fa039eb8faf20fccde4108dad115df389e81f3
|
7
|
+
data.tar.gz: 191b9afc5308b6bdb8fd2c9ce315b0bad32b8dcec339d11726e0661a1869fa5a03e3ca24b2c0e6d5bba797237935951eee4371e4ba9ebf08c777cf29aea7f991
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
1
7
|
## [Unreleased]
|
2
8
|
|
9
|
+
## [0.7.2] - 2023-05-02
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
|
13
|
+
- Fix more module names in ActiveRecord v6 adapter (`CipherstashPG` -> `CiphStashPG`).
|
14
|
+
|
15
|
+
## [0.7.1] - 2023-05-02
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Bump version of cipherstash-pg.
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
|
23
|
+
- Fix module names in ActiveRecord 6 adapter
|
24
|
+
|
25
|
+
## [0.7.0] - 2023-05-01
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
|
29
|
+
- Update PG namespace to use CipherStashPG.
|
30
|
+
- Bump version of cipherstash-pg.
|
31
|
+
|
3
32
|
## [0.6.1] - 2023-04-26
|
4
33
|
|
5
34
|
### Fixed
|
@@ -33,6 +62,7 @@
|
|
33
62
|
- Bump version of cipherstash-pg.
|
34
63
|
|
35
64
|
## [0.3.0] - 2023-04-04
|
65
|
+
|
36
66
|
### Added
|
37
67
|
|
38
68
|
- Support for both Rails 6 + 7.
|
data/README.md
CHANGED
@@ -26,7 +26,12 @@ development:
|
|
26
26
|
|
27
27
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
28
|
|
29
|
-
To release a new version
|
29
|
+
To release a new version:
|
30
|
+
|
31
|
+
- update the version number in `version.rb`.
|
32
|
+
- update the CHANGELOG.
|
33
|
+
- raise a PR and merge.
|
34
|
+
- run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
35
|
|
31
36
|
In the github repo:
|
32
37
|
|
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
# Runtime dependencies here; dev+test go in Gemfile.
|
33
33
|
spec.add_dependency "activerecord", ">= 6.0.0", "< 8.0.0"
|
34
|
-
spec.add_dependency "cipherstash-pg", ">= 1.0.0.beta.
|
34
|
+
spec.add_dependency "cipherstash-pg", ">= 1.0.0.beta.4"
|
35
35
|
end
|
@@ -38,8 +38,8 @@ module ActiveRecord
|
|
38
38
|
conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
|
39
39
|
conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
|
40
40
|
|
41
|
-
# Forward only valid config params to
|
42
|
-
valid_conn_param_keys =
|
41
|
+
# Forward only valid config params to ::CipherStashPG::Connection.connect.
|
42
|
+
valid_conn_param_keys = ::CipherStashPG::Connection.conndefaults_hash.keys + [:requiressl]
|
43
43
|
conn_params.slice!(*valid_conn_param_keys)
|
44
44
|
|
45
45
|
ConnectionAdapters::CipherStashPGAdapter.new(
|
@@ -58,7 +58,7 @@ module ActiveRecord
|
|
58
58
|
class << self
|
59
59
|
def new_client(conn_params)
|
60
60
|
::CipherStashPG.connect(**conn_params)
|
61
|
-
rescue ::
|
61
|
+
rescue ::CipherStashPG::Error => error
|
62
62
|
if conn_params && conn_params[:dbname] && error.message.include?(conn_params[:dbname])
|
63
63
|
raise ActiveRecord::NoDatabaseError
|
64
64
|
else
|
@@ -215,12 +215,12 @@ module ActiveRecord
|
|
215
215
|
private
|
216
216
|
def dealloc(key)
|
217
217
|
@connection.query "DEALLOCATE #{key}" if connection_active?
|
218
|
-
rescue
|
218
|
+
rescue ::CipherStashPG::Error
|
219
219
|
end
|
220
220
|
|
221
221
|
def connection_active?
|
222
|
-
@connection.status ==
|
223
|
-
rescue
|
222
|
+
@connection.status == ::CipherStashPG::CONNECTION_OK
|
223
|
+
rescue ::CipherStashPG::Error
|
224
224
|
false
|
225
225
|
end
|
226
226
|
end
|
@@ -257,7 +257,7 @@ module ActiveRecord
|
|
257
257
|
@connection.query "SELECT 1"
|
258
258
|
end
|
259
259
|
true
|
260
|
-
rescue
|
260
|
+
rescue ::CipherStashPG::Error
|
261
261
|
false
|
262
262
|
end
|
263
263
|
|
@@ -267,7 +267,7 @@ module ActiveRecord
|
|
267
267
|
super
|
268
268
|
@connection.reset
|
269
269
|
configure_connection
|
270
|
-
rescue
|
270
|
+
rescue ::CipherStashPG::ConnectionBad
|
271
271
|
connect
|
272
272
|
end
|
273
273
|
end
|
@@ -276,7 +276,7 @@ module ActiveRecord
|
|
276
276
|
@lock.synchronize do
|
277
277
|
clear_cache!
|
278
278
|
reset_transaction
|
279
|
-
unless @connection.transaction_status == ::
|
279
|
+
unless @connection.transaction_status == ::CipherStashPG::PQTRANS_IDLE
|
280
280
|
@connection.query "ROLLBACK"
|
281
281
|
end
|
282
282
|
@connection.query "DISCARD ALL"
|
@@ -450,7 +450,7 @@ module ActiveRecord
|
|
450
450
|
def translate_exception(exception, message:, sql:, binds:)
|
451
451
|
return exception unless exception.respond_to?(:result)
|
452
452
|
|
453
|
-
case exception.result.try(:error_field,
|
453
|
+
case exception.result.try(:error_field, ::CipherStashPG::PG_DIAG_SQLSTATE)
|
454
454
|
when nil
|
455
455
|
if exception.message.match?(/connection is closed/i)
|
456
456
|
ConnectionNotEstablished.new(exception)
|
@@ -550,7 +550,7 @@ module ActiveRecord
|
|
550
550
|
# places before decimal = (fmod - 4) >> 16 & 0xffff
|
551
551
|
if fmod && (fmod - 4 & 0xffff).zero?
|
552
552
|
# FIXME: Remove this class, and the second argument to
|
553
|
-
# lookups on
|
553
|
+
# lookups on ::CipherStashPG
|
554
554
|
Type::DecimalWithoutScale.new(precision: precision)
|
555
555
|
else
|
556
556
|
OID::Decimal.new(precision: precision, scale: scale)
|
@@ -704,8 +704,8 @@ module ActiveRecord
|
|
704
704
|
# https://git.cipherstash_pg.org/gitweb/?p=cipherstash_pg.git;a=blob;f=src/backend/utils/cache/plancache.c#l573
|
705
705
|
def is_cached_plan_failure?(e)
|
706
706
|
pgerror = e.cause
|
707
|
-
pgerror.result.result_error_field(
|
708
|
-
pgerror.result.result_error_field(
|
707
|
+
pgerror.result.result_error_field(::CipherStashPG::PG_DIAG_SQLSTATE) == FEATURE_NOT_SUPPORTED &&
|
708
|
+
pgerror.result.result_error_field(::CipherStashPG::PG_DIAG_SOURCE_FUNCTION) == "RevalidateCachedQuery"
|
709
709
|
rescue
|
710
710
|
false
|
711
711
|
end
|
@@ -870,18 +870,18 @@ module ActiveRecord
|
|
870
870
|
end
|
871
871
|
|
872
872
|
def add_pg_encoders
|
873
|
-
map =
|
874
|
-
map[Integer] =
|
875
|
-
map[TrueClass] =
|
876
|
-
map[FalseClass] =
|
873
|
+
map = ::CipherStashPG::TypeMapByClass.new
|
874
|
+
map[Integer] = ::CipherStashPG::TextEncoder::Integer.new
|
875
|
+
map[TrueClass] = ::CipherStashPG::TextEncoder::Boolean.new
|
876
|
+
map[FalseClass] = ::CipherStashPG::TextEncoder::Boolean.new
|
877
877
|
@connection.type_map_for_queries = map
|
878
878
|
end
|
879
879
|
|
880
880
|
def update_typemap_for_default_timezone
|
881
881
|
if @default_timezone != ActiveRecord::Base.default_timezone && @timestamp_decoder
|
882
882
|
decoder_class = ActiveRecord::Base.default_timezone == :utc ?
|
883
|
-
|
884
|
-
|
883
|
+
::CipherStashPG::TextDecoder::TimestampUtc :
|
884
|
+
::CipherStashPG::TextDecoder::TimestampWithoutTimeZone
|
885
885
|
|
886
886
|
@timestamp_decoder = decoder_class.new(@timestamp_decoder.to_h)
|
887
887
|
@connection.type_map_for_results.add_coder(@timestamp_decoder)
|
@@ -894,16 +894,16 @@ module ActiveRecord
|
|
894
894
|
@timestamp_decoder = nil
|
895
895
|
|
896
896
|
coders_by_name = {
|
897
|
-
"int2" =>
|
898
|
-
"int4" =>
|
899
|
-
"int8" =>
|
900
|
-
"oid" =>
|
901
|
-
"float4" =>
|
902
|
-
"float8" =>
|
903
|
-
"numeric" =>
|
904
|
-
"bool" =>
|
905
|
-
"timestamp" =>
|
906
|
-
"timestamptz" =>
|
897
|
+
"int2" => ::CipherStashPG::TextDecoder::Integer,
|
898
|
+
"int4" => ::CipherStashPG::TextDecoder::Integer,
|
899
|
+
"int8" => ::CipherStashPG::TextDecoder::Integer,
|
900
|
+
"oid" => ::CipherStashPG::TextDecoder::Integer,
|
901
|
+
"float4" => ::CipherStashPG::TextDecoder::Float,
|
902
|
+
"float8" => ::CipherStashPG::TextDecoder::Float,
|
903
|
+
"numeric" => ::CipherStashPG::TextDecoder::Numeric,
|
904
|
+
"bool" => ::CipherStashPG::TextDecoder::Boolean,
|
905
|
+
"timestamp" => ::CipherStashPG::TextDecoder::TimestampUtc,
|
906
|
+
"timestamptz" => ::CipherStashPG::TextDecoder::TimestampWithTimeZone,
|
907
907
|
}
|
908
908
|
|
909
909
|
known_coder_types = coders_by_name.keys.map { |n| quote(n) }
|
@@ -918,13 +918,13 @@ module ActiveRecord
|
|
918
918
|
.compact
|
919
919
|
end
|
920
920
|
|
921
|
-
map =
|
921
|
+
map = ::CipherStashPG::TypeMapByOid.new
|
922
922
|
coders.each { |coder| map.add_coder(coder) }
|
923
923
|
@connection.type_map_for_results = map
|
924
924
|
|
925
|
-
@type_map_for_results =
|
925
|
+
@type_map_for_results = ::CipherStashPG::TypeMapByOid.new
|
926
926
|
@type_map_for_results.default_type_map = map
|
927
|
-
@type_map_for_results.add_coder(
|
927
|
+
@type_map_for_results.add_coder(::CipherStashPG::TextDecoder::Bytea.new(oid: 17, name: "bytea"))
|
928
928
|
@type_map_for_results.add_coder(MoneyDecoder.new(oid: 790, name: "money"))
|
929
929
|
|
930
930
|
# extract timestamp decoder for use in update_typemap_for_default_timezone
|
@@ -937,7 +937,7 @@ module ActiveRecord
|
|
937
937
|
coder_class.new(oid: row["oid"].to_i, name: row["typname"])
|
938
938
|
end
|
939
939
|
|
940
|
-
class MoneyDecoder <
|
940
|
+
class MoneyDecoder < ::CipherStashPG::SimpleDecoder # :nodoc:
|
941
941
|
TYPE = OID::Money.new
|
942
942
|
|
943
943
|
def decode(value, tuple = nil, field = nil)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-cipherstash-pg-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Howard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.0.0.beta.
|
39
|
+
version: 1.0.0.beta.4
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.0.0.beta.
|
46
|
+
version: 1.0.0.beta.4
|
47
47
|
description: CipherStash PostgreSQL adapter for ActiveRecord.
|
48
48
|
email:
|
49
49
|
- robin@cipherstash.com
|