activerecord-oracle_enhanced-adapter 7.0.0 → 7.0.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: 28b353a0c4917c1696bc44c5c3e60565c2863fc6639e48ff71814064394497a5
4
- data.tar.gz: bdf94614cb38f1ad7ab121f580164ccb48e974ac7f09bcce3bbdfaca7cc51ca8
3
+ metadata.gz: d62d90d3ee110795b7396cd404a1e9c7dd5d61b9d11685b0a935a4c93f276cd3
4
+ data.tar.gz: fb3e1420b6ed0ddcc98631da947081f69543f8fe8ac42551a4a980f39b038fd2
5
5
  SHA512:
6
- metadata.gz: b0586d8753686b7f81a2b8137397fe0ab9af4f0607775f866f06e0625d9dc9eae480093bbb73f9331798dcba124b5d0b86039d06e039827281cbb05ba2e9b0dc
7
- data.tar.gz: 90c2613d22b1705db2f82d5dca382327c3b4c36edba9ac46879441614b143e136e054eed07aebb2f12b06aac95e7d89e17021ac62dfb22f8efaa67206577d341
6
+ metadata.gz: 1e9ee5b06389da2923f6485412ea2753f2537c4ac7f6e2ba9afd2e8189347aa97313c9273de617f3375a593f310262902bbf7e5ffabc5fd75c44da5870026fe4
7
+ data.tar.gz: 7da3548a2d4f594b213ace0a2b3e016b44a6767c284970258db595f23dba952d83ddde919d49f1d98e2359ae74c2ac0adbb0b65ecf18bb33d67d58bb891d90b8
data/History.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 7.0.1 / 2022-01-13
2
+
3
+ * Changes and bug fixes
4
+ * Add ruby-oci8 as dependency only for CRuby [#2238 #2240 #2243]
5
+ * Add if_exists option to remove_index [#2219 #2233]
6
+ * all attributes serialized before writing [#2203 #2234]
7
+ * Require 'activerecord', not 'rails' not to attempt to install digest [#2241]
8
+ * CI
9
+ * Bump Ruby versions at Travis CI [#2242]
10
+ * CI against Ruby 3.1 at GitHub Actions [#2235 #2244]
1
11
  ## 7.0.0 / 2021-12-16
2
12
  * Changes and bug fixes
3
13
  * Support Rails 7.0.0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.0.0
1
+ 7.0.1
@@ -254,11 +254,9 @@ module ActiveRecord
254
254
  value = attributes[col.name]
255
255
  # changed sequence of next two lines - should check if value is nil before converting to yaml
256
256
  next unless value
257
- if klass.attribute_types[col.name].is_a? Type::Serialized
258
- value = klass.attribute_types[col.name].serialize(value)
259
- # value can be nil after serialization because ActiveRecord serializes [] and {} as nil
260
- next unless value
261
- end
257
+ value = klass.attribute_types[col.name].serialize(value)
258
+ # value can be nil after serialization because ActiveRecord serializes [] and {} as nil
259
+ next unless value
262
260
  uncached do
263
261
  unless lob_record = select_one(sql = <<~SQL.squish, "Writable Large Object")
264
262
  SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)}
@@ -330,6 +330,8 @@ module ActiveRecord
330
330
  # Remove the given index from the table.
331
331
  # Gives warning if index does not exist
332
332
  def remove_index(table_name, column_name = nil, **options) # :nodoc:
333
+ return if options[:if_exists] && !index_exists?(table_name, column_name, **options)
334
+
333
335
  index_name = index_name_for_remove(table_name, column_name, options)
334
336
  # TODO: It should execute only when index_type == "UNIQUE"
335
337
  execute "ALTER TABLE #{quote_table_name(table_name)} DROP CONSTRAINT #{quote_column_name(index_name)}" rescue nil
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe "OracleEnhancedAdapter custom types handling" do
4
+ include SchemaSpecHelper
5
+
6
+ before(:all) do
7
+ ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
8
+ schema_define do
9
+ create_table :test_employees, force: true do |t|
10
+ t.string :first_name, limit: 20
11
+ t.string :last_name, limit: 25
12
+ t.text :signature
13
+ end
14
+ end
15
+
16
+ class TestEmployee < ActiveRecord::Base
17
+ class AttributeSignature < ActiveRecord::Type::Text
18
+ def cast(value)
19
+ case value
20
+ when Signature
21
+ value
22
+ when nil
23
+ nil
24
+ else
25
+ Signature.new(Base64.decode64 value)
26
+ end
27
+ end
28
+
29
+ def serialize(value)
30
+ Base64.encode64 value.raw
31
+ end
32
+
33
+ def changed_in_place?(raw_old_value, new_value)
34
+ new_value != cast(raw_old_value)
35
+ end
36
+ end
37
+
38
+ class Signature
39
+ attr_reader :raw
40
+
41
+ def initialize(raw_value)
42
+ @raw = raw_value
43
+ end
44
+
45
+ def to_s
46
+ "Signature nice string #{raw[0..5]}"
47
+ end
48
+
49
+ def ==(object)
50
+ raw == object&.raw
51
+ end
52
+ alias eql? ==
53
+ end
54
+
55
+ attribute :signature, AttributeSignature.new
56
+ end
57
+ end
58
+
59
+ after(:all) do
60
+ schema_define do
61
+ drop_table :test_employees
62
+ end
63
+ Object.send(:remove_const, "TestEmployee")
64
+ ActiveRecord::Base.clear_cache!
65
+ end
66
+
67
+ it "should serialize LOBs when creating a record" do
68
+ raw_signature = "peter'ssignature"
69
+ signature = TestEmployee::Signature.new(raw_signature)
70
+ @employee = TestEmployee.create!(first_name: "Peter", last_name: "Doe", signature: signature)
71
+ @employee.reload
72
+ expect(@employee.signature).to eql(signature)
73
+ expect(@employee.signature).to_not be(signature)
74
+ expect(TestEmployee.first.read_attribute_before_type_cast(:signature)).to eq(Base64.encode64 raw_signature)
75
+ end
76
+
77
+ it "should serialize LOBs when updating a record" do
78
+ raw_signature = "peter'ssignature"
79
+ signature = TestEmployee::Signature.new(raw_signature)
80
+ @employee = TestEmployee.create!(first_name: "Peter", last_name: "Doe", signature: TestEmployee::Signature.new("old signature"))
81
+ @employee.signature = signature
82
+ @employee.save!
83
+ @employee.reload
84
+ expect(@employee.signature).to eql(signature)
85
+ expect(@employee.signature).to_not be(signature)
86
+ expect(TestEmployee.first.read_attribute_before_type_cast(:signature)).to eq(Base64.encode64 raw_signature)
87
+ end
88
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-oracle_enhanced-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-16 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.6.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: ruby-oci8
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: |
42
56
  Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
43
57
  This adapter is superset of original ActiveRecord Oracle adapter.
@@ -103,6 +117,7 @@ files:
103
117
  - spec/active_record/oracle_enhanced/type/binary_spec.rb
104
118
  - spec/active_record/oracle_enhanced/type/boolean_spec.rb
105
119
  - spec/active_record/oracle_enhanced/type/character_string_spec.rb
120
+ - spec/active_record/oracle_enhanced/type/custom_spec.rb
106
121
  - spec/active_record/oracle_enhanced/type/decimal_spec.rb
107
122
  - spec/active_record/oracle_enhanced/type/dirty_spec.rb
108
123
  - spec/active_record/oracle_enhanced/type/float_spec.rb
@@ -137,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
152
  - !ruby/object:Gem::Version
138
153
  version: 1.8.11
139
154
  requirements: []
140
- rubygems_version: 3.2.32
155
+ rubygems_version: 3.3.3
141
156
  signing_key:
142
157
  specification_version: 4
143
158
  summary: Oracle enhanced adapter for ActiveRecord
@@ -157,6 +172,7 @@ test_files:
157
172
  - spec/active_record/oracle_enhanced/type/binary_spec.rb
158
173
  - spec/active_record/oracle_enhanced/type/boolean_spec.rb
159
174
  - spec/active_record/oracle_enhanced/type/character_string_spec.rb
175
+ - spec/active_record/oracle_enhanced/type/custom_spec.rb
160
176
  - spec/active_record/oracle_enhanced/type/decimal_spec.rb
161
177
  - spec/active_record/oracle_enhanced/type/dirty_spec.rb
162
178
  - spec/active_record/oracle_enhanced/type/float_spec.rb