activerecord-oracle_enhanced-adapter 1.7.0.beta7 → 1.7.0.rc1
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/History.md +22 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +10 -7
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +43 -20
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +7 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 766d556c9fdb716de4aecfd9856f94187f11ea9f
|
4
|
+
data.tar.gz: 3e0df68d291259d67fbc4b020b10c0aa876204d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 073a8f2e716f1090227ce6296b6cbdc0f489fa77b158a5d0bb03011f24ea1c2f2d643c560ba87afa6007547961924a2ca9984658dc36f1a547ef7509126a548e
|
7
|
+
data.tar.gz: 1fb80f53dc9a0398ef762b5d96c20230c331435371b7237d2241b6eb32784716366feeb4e7f304c0aeaf0f1f116f4746225679108de748380fc4ffd43d6cd927
|
data/History.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 1.7.0.rc1 / 2016-08-02
|
2
|
+
|
3
|
+
* Changes and bug fixes
|
4
|
+
|
5
|
+
* Support `emulate_booleans_from_strings` in Rails 5 [#953, #942]
|
6
|
+
* Deprecate `self.is_boolean_column?` [#949]
|
7
|
+
* Deprecate `self.is_date_column?` and `is_date_column?` [#950]
|
8
|
+
* Deprecate `set_type_for_columns`, `set_type_for_columns` and `clear_types_for_columns` [#951]
|
9
|
+
* Deprecate `self.is_integer_column?` [#952]
|
10
|
+
|
11
|
+
* Known issues
|
12
|
+
|
13
|
+
- Only with JRuby
|
14
|
+
* Rails 5 : explain should explain query with binds got Java::JavaSql::SQLException: Invalid column index [#908]
|
15
|
+
* Workaround: execute explain without bind or use CRuby
|
16
|
+
- CRuby and JRuby
|
17
|
+
* Rails 5 : custom methods for create record when exception is raised in after_create callback fails [#944]
|
18
|
+
* Rails 5 : specs need update to emulate_booleans_from_strings [#942]
|
19
|
+
* Rails 5 : undefined method `to_i' for #<Arel::Nodes::BindParam:0x00000002c92910> [#848, rails/arel#438]
|
20
|
+
* #848 reproduces when database version is 11gR2 or older, it does not reproduce with 12c
|
21
|
+
* One of the units test skipped when database version is 11gR2 or lower. [#946]
|
22
|
+
|
1
23
|
## 1.7.0.beta7 / 2016-08-01
|
2
24
|
|
3
25
|
* Changes and bug fixes
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Oracle enhanced adapter Rails 5 support is still in beta release, so use with ca
|
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
# Use oracle as the database for Active Record
|
21
|
-
gem 'activerecord-oracle_enhanced-adapter', '~> 1.7.0.
|
21
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 1.7.0.rc1'
|
22
22
|
```
|
23
23
|
|
24
24
|
### Rails 4.2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.0.
|
1
|
+
1.7.0.rc1
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{activerecord-oracle_enhanced-adapter}
|
3
|
-
s.version = "1.7.0.
|
3
|
+
s.version = "1.7.0.rc1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.required_ruby_version = '>= 2.2.2'
|
7
7
|
s.license = 'MIT'
|
8
8
|
s.authors = [%q{Raimonds Simanovskis}]
|
9
|
-
s.date = %q{2016-08-
|
9
|
+
s.date = %q{2016-08-02}
|
10
10
|
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
11
11
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
12
12
|
}
|
@@ -106,11 +106,21 @@ module ActiveRecord
|
|
106
106
|
"1"
|
107
107
|
end
|
108
108
|
|
109
|
+
def unquoted_true #:nodoc:
|
110
|
+
return "#{self.class.boolean_to_string(true)}" if emulate_booleans_from_strings
|
111
|
+
"1".freeze
|
112
|
+
end
|
113
|
+
|
109
114
|
def quoted_false #:nodoc:
|
110
115
|
return "'#{self.class.boolean_to_string(false)}'" if emulate_booleans_from_strings
|
111
116
|
"0"
|
112
117
|
end
|
113
118
|
|
119
|
+
def unquoted_false #:nodoc:
|
120
|
+
return "#{self.class.boolean_to_string(false)}" if emulate_booleans_from_strings
|
121
|
+
"0".freeze
|
122
|
+
end
|
123
|
+
|
114
124
|
def quote_date_with_to_date(value) #:nodoc:
|
115
125
|
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
116
126
|
`quote_date_with_to_date` will be deprecated in future version of Oracle enhanced adapter.
|
@@ -138,13 +148,6 @@ module ActiveRecord
|
|
138
148
|
|
139
149
|
def _type_cast(value)
|
140
150
|
case value
|
141
|
-
when true, false
|
142
|
-
#if emulate_booleans_from_strings || column && column.type == :string
|
143
|
-
if emulate_booleans_from_strings
|
144
|
-
self.class.boolean_to_string(value)
|
145
|
-
else
|
146
|
-
value ? 1 : 0
|
147
|
-
end
|
148
151
|
when Date, Time
|
149
152
|
if value.acts_like?(:time)
|
150
153
|
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
|
@@ -303,19 +303,27 @@ module ActiveRecord
|
|
303
303
|
# Is used if +emulate_dates_by_column_name+ option is set to +true+.
|
304
304
|
# Override this method definition in initializer file if different Date column recognition is needed.
|
305
305
|
def self.is_date_column?(name, table_name = nil)
|
306
|
-
|
306
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
307
|
+
`self.is_date_column?` has been deprecated. Please use Rails attribute API.
|
308
|
+
MSG
|
309
|
+
return false
|
310
|
+
# name =~ /(^|_)date(_|$)/i
|
307
311
|
end
|
308
312
|
|
309
313
|
# instance method uses at first check if column type defined at class level
|
310
314
|
def is_date_column?(name, table_name = nil) #:nodoc:
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
315
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
316
|
+
`is_date_column?` has been deprecated. Please use Rails attribute API.
|
317
|
+
MSG
|
318
|
+
return false
|
319
|
+
#case get_type_for_column(table_name, name)
|
320
|
+
#when nil
|
321
|
+
# self.class.is_date_column?(name, table_name)
|
322
|
+
#when :date
|
323
|
+
# true
|
324
|
+
#else
|
325
|
+
# false
|
326
|
+
#end
|
319
327
|
end
|
320
328
|
|
321
329
|
##
|
@@ -333,7 +341,10 @@ module ActiveRecord
|
|
333
341
|
# Is used if +emulate_integers_by_column_name+ option is set to +true+.
|
334
342
|
# Override this method definition in initializer file if different Integer column recognition is needed.
|
335
343
|
def self.is_integer_column?(name, table_name = nil)
|
336
|
-
|
344
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
345
|
+
`is_integer_column?` has been deprecated. Please use Rails attribute API.
|
346
|
+
MSG
|
347
|
+
return false
|
337
348
|
end
|
338
349
|
|
339
350
|
##
|
@@ -349,8 +360,12 @@ module ActiveRecord
|
|
349
360
|
# Is used if +emulate_booleans_from_strings+ option is set to +true+.
|
350
361
|
# Override this method definition in initializer file if different boolean column recognition is needed.
|
351
362
|
def self.is_boolean_column?(name, sql_type, table_name = nil)
|
352
|
-
|
353
|
-
|
363
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
364
|
+
`is_boolean_column?` has been deprecated. Please use Rails attribute API.
|
365
|
+
MSG
|
366
|
+
return false
|
367
|
+
# return true if ["CHAR(1)","VARCHAR2(1)"].include?(sql_type)
|
368
|
+
# sql_type =~ /^VARCHAR2/ && (name =~ /_flag$/i || name =~ /_yn$/i)
|
354
369
|
end
|
355
370
|
|
356
371
|
# How boolean value should be quoted to String.
|
@@ -880,20 +895,22 @@ module ActiveRecord
|
|
880
895
|
|
881
896
|
# set explicit type for specified table columns
|
882
897
|
def set_type_for_columns(table_name, column_type, *args) #:nodoc:
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
@@table_column_type[table_name][col.to_s.downcase] = column_type
|
887
|
-
end
|
898
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
899
|
+
`set_type_for_columns` has been deprecated. Please use Rails attribute API.
|
900
|
+
MSG
|
888
901
|
end
|
889
902
|
|
890
903
|
def get_type_for_column(table_name, column_name) #:nodoc:
|
891
|
-
|
904
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
905
|
+
`get_type_for_columns` has been deprecated. Please use Rails attribute API.
|
906
|
+
MSG
|
892
907
|
end
|
893
908
|
|
894
909
|
# used just in tests to clear column data type definitions
|
895
910
|
def clear_types_for_columns #:nodoc:
|
896
|
-
|
911
|
+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
|
912
|
+
`clear_types_for_columns` has been deprecated. Please use Rails attribute API.
|
913
|
+
MSG
|
897
914
|
end
|
898
915
|
|
899
916
|
# check if table has primary key trigger with _pkt suffix
|
@@ -1176,7 +1193,13 @@ module ActiveRecord
|
|
1176
1193
|
end
|
1177
1194
|
end
|
1178
1195
|
|
1179
|
-
|
1196
|
+
if OracleEnhancedAdapter.emulate_booleans
|
1197
|
+
if OracleEnhancedAdapter.emulate_booleans_from_strings
|
1198
|
+
m.register_type %r(^VARCHAR2\(1\))i, Type::Boolean.new
|
1199
|
+
else
|
1200
|
+
m.register_type %r(^NUMBER\(1\))i, Type::Boolean.new
|
1201
|
+
end
|
1202
|
+
end
|
1180
1203
|
end
|
1181
1204
|
|
1182
1205
|
def extract_limit(sql_type) #:nodoc:
|
@@ -58,7 +58,6 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
|
|
58
58
|
after(:each) do
|
59
59
|
# @employee.destroy if @employee
|
60
60
|
Object.send(:remove_const, "TestEmployee")
|
61
|
-
@conn.clear_types_for_columns
|
62
61
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
63
62
|
end
|
64
63
|
|
@@ -186,7 +185,6 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
186
185
|
|
187
186
|
after(:each) do
|
188
187
|
Object.send(:remove_const, "Test2Employee")
|
189
|
-
@conn.clear_types_for_columns
|
190
188
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
|
191
189
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
192
190
|
end
|
@@ -312,14 +310,13 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
312
310
|
|
313
311
|
after(:each) do
|
314
312
|
Object.send(:remove_const, "Test3Employee")
|
315
|
-
@conn.clear_types_for_columns
|
316
313
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
317
314
|
end
|
318
315
|
|
319
316
|
describe "default values in new records" do
|
320
317
|
context "when emulate_booleans_from_strings is false" do
|
321
318
|
before do
|
322
|
-
|
319
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
323
320
|
end
|
324
321
|
|
325
322
|
it "are Y or N" do
|
@@ -331,7 +328,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
331
328
|
|
332
329
|
context "when emulate_booleans_from_strings is true" do
|
333
330
|
before do
|
334
|
-
|
331
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
335
332
|
end
|
336
333
|
|
337
334
|
it "are True or False" do
|
@@ -347,18 +344,17 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
347
344
|
end
|
348
345
|
|
349
346
|
it "should translate boolean type to NUMBER(1) if emulate_booleans_from_strings is false" do
|
350
|
-
|
347
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
351
348
|
expect(ActiveRecord::Base.connection.type_to_sql(
|
352
349
|
:boolean, nil, nil, nil)).to eq("NUMBER(1)")
|
353
350
|
end
|
354
351
|
|
355
352
|
describe "/ VARCHAR2 boolean values from ActiveRecord model" do
|
356
353
|
before(:each) do
|
357
|
-
|
354
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
358
355
|
end
|
359
356
|
|
360
357
|
after(:each) do
|
361
|
-
@conn.clear_types_for_columns
|
362
358
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
363
359
|
end
|
364
360
|
|
@@ -377,7 +373,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
377
373
|
end
|
378
374
|
|
379
375
|
it "should return String value from VARCHAR2 boolean column if emulate_booleans_from_strings is false" do
|
380
|
-
|
376
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
381
377
|
create_employee3
|
382
378
|
%w(has_email has_phone active_flag manager_yn).each do |col|
|
383
379
|
expect(@employee3.send(col.to_sym).class).to eq(String)
|
@@ -404,7 +400,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
404
400
|
end
|
405
401
|
|
406
402
|
it "should return string value from VARCHAR2 column if it is not boolean column and emulate_booleans_from_strings is true" do
|
407
|
-
|
403
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
408
404
|
create_employee3
|
409
405
|
expect(@employee3.first_name.class).to eq(String)
|
410
406
|
end
|
@@ -430,7 +426,7 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
430
426
|
end
|
431
427
|
|
432
428
|
it "should return string value from VARCHAR2 column with boolean column name but is specified in set_string_columns" do
|
433
|
-
|
429
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
434
430
|
# Test3Employee.set_string_columns :active_flag
|
435
431
|
class ::Test3Employee < ActiveRecord::Base
|
436
432
|
attribute :active_flag, :string
|
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: 1.7.0.
|
4
|
+
version: 1.7.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|