activerecord-oracle_enhanced-adapter 1.7.0.beta1 → 1.7.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +47 -7
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +4 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +3 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +0 -9
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +0 -179
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +0 -18
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +0 -46
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +0 -23
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bfe3790c7fd04db5135ae542ed043d6cf3d841c
|
4
|
+
data.tar.gz: b9a99140af3273a2106d29f2c01c24fe7d247913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e741ac73131eb73c8a1156fd90927db6777bef7306fced5df9bb6e58860057138077f91bc08b956e6ac924c50edfcd866e7ff3b05487ef9f4849e53b8c8a0ec3
|
7
|
+
data.tar.gz: 9b744df558be9c9dab4abca0127791d0792d50c405bbdafe0c6013528df8db20c491cdd33a739d53f23dfcbb21c2f10a671ba90fd26e07f4f3dfc1780d93934d
|
data/Gemfile
CHANGED
@@ -5,7 +5,7 @@ group :development do
|
|
5
5
|
gem 'rdoc'
|
6
6
|
gem 'rake'
|
7
7
|
|
8
|
-
gem 'activerecord', github: 'rails/rails', branch: '
|
8
|
+
gem 'activerecord', github: 'rails/rails', branch: '5-0-stable'
|
9
9
|
gem 'rack', github: 'rack/rack', branch: 'master'
|
10
10
|
gem 'arel', github: 'rails/arel', branch: 'master'
|
11
11
|
|
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', '
|
21
|
+
gem 'activerecord-oracle_enhanced-adapter', '~> 1.7.0.beta1'
|
22
22
|
```
|
23
23
|
|
24
24
|
### Rails 4.2
|
@@ -258,14 +258,17 @@ class Employee < ActiveRecord::Base
|
|
258
258
|
# specify sequence name
|
259
259
|
self.sequence_name = "hr.hr_employee_s"
|
260
260
|
|
261
|
-
# set which DATE columns should be converted to Ruby Date
|
262
|
-
|
261
|
+
# set which DATE columns should be converted to Ruby Date using ActiveRecord Attribute API
|
262
|
+
# Starting from Oracle enhanced adapter 1.7 Oracle `DATE` columns are mapped to Ruby `Date` by default.
|
263
|
+
attribute :hired_on, :date
|
264
|
+
attribute :birth_date_on, :date
|
263
265
|
|
264
|
-
# set which DATE columns should be converted to Ruby Time
|
265
|
-
|
266
|
+
# set which DATE columns should be converted to Ruby Time using ActiveRecord Attribute API
|
267
|
+
attribute :last_login_time, :datetime
|
266
268
|
|
267
|
-
# set which VARCHAR2 columns should be converted to true and false
|
268
|
-
|
269
|
+
# set which VARCHAR2 columns should be converted to true and false using ActiveRecord Attribute API
|
270
|
+
attribute :manager, :boolean
|
271
|
+
attribute :active, :boolean
|
269
272
|
|
270
273
|
# set which columns should be ignored in ActiveRecord
|
271
274
|
ignore_table_columns :attribute1, :attribute2
|
@@ -278,6 +281,35 @@ You can also access remote tables over database link using
|
|
278
281
|
self.table_name "hr_employees@db_link"
|
279
282
|
```
|
280
283
|
|
284
|
+
Examples for Rails 4.x
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
class Employee < ActiveRecord::Base
|
288
|
+
# specify schema and table name
|
289
|
+
self.table_name = "hr.hr_employees"
|
290
|
+
|
291
|
+
# specify primary key name
|
292
|
+
self.primary_key = "employee_id"
|
293
|
+
|
294
|
+
# specify sequence name
|
295
|
+
self.sequence_name = "hr.hr_employee_s"
|
296
|
+
|
297
|
+
# If you're using Rails 4.2 or earlier you can do this
|
298
|
+
|
299
|
+
# set which DATE columns should be converted to Ruby Date
|
300
|
+
set_date_columns :hired_on, :birth_date_on
|
301
|
+
|
302
|
+
# set which DATE columns should be converted to Ruby Time
|
303
|
+
set_datetime_columns :last_login_time
|
304
|
+
|
305
|
+
# set which VARCHAR2 columns should be converted to true and false
|
306
|
+
set_boolean_columns :manager, :active
|
307
|
+
|
308
|
+
# set which columns should be ignored in ActiveRecord
|
309
|
+
ignore_table_columns :attribute1, :attribute2
|
310
|
+
end
|
311
|
+
```
|
312
|
+
|
281
313
|
Examples for Rails 3.2 and lower version of Rails
|
282
314
|
|
283
315
|
```ruby
|
@@ -429,6 +461,14 @@ Post.contains(:all_text, "aaa within title")
|
|
429
461
|
Post.contains(:all_text, "bbb within comment_author")
|
430
462
|
```
|
431
463
|
|
464
|
+
Please note that `index_column` must be a real column in your database and it's value will be overriden every time your `index_column_trigger_on` columns are changed. So, _do not use columns with real data as `index_column`_.
|
465
|
+
|
466
|
+
Index column can be created as:
|
467
|
+
|
468
|
+
```ruby
|
469
|
+
add_column :posts, :all_text, :string, limit: 2, comment: 'Service column for context search index'
|
470
|
+
```
|
471
|
+
|
432
472
|
### Oracle virtual columns support
|
433
473
|
|
434
474
|
Since version R11G1 Oracle database allows adding computed [Virtual Columns](http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php) to the table.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.0.
|
1
|
+
1.7.0.beta2
|
@@ -1,11 +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.beta2"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.required_ruby_version = '>= 2.2.2'
|
6
7
|
s.license = 'MIT'
|
7
8
|
s.authors = [%q{Raimonds Simanovskis}]
|
8
|
-
s.date = %q{2016-07-
|
9
|
+
s.date = %q{2016-07-22}
|
9
10
|
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
10
11
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
11
12
|
}
|
@@ -87,7 +88,7 @@ This adapter is superset of original ActiveRecord Oracle adapter.
|
|
87
88
|
]
|
88
89
|
s.add_dependency(%q<rspec>, ["~> 3.3"])
|
89
90
|
s.add_dependency(%q<activerecord>, ["~> 5.0.0"])
|
90
|
-
s.add_dependency(%q<arel>, ["~> 7.0"])
|
91
|
+
s.add_dependency(%q<arel>, ["~> 7.1.0"])
|
91
92
|
s.add_dependency(%q<ruby-plsql>, [">= 0.5.0"])
|
92
93
|
s.add_dependency(%q<ruby-oci8>, [">= 2.2.0"]) if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
|
93
94
|
s.license = 'MIT'
|
@@ -361,7 +361,7 @@ module ActiveRecord
|
|
361
361
|
@raw_statement.setBigDecimal(position, value)
|
362
362
|
when Java::OracleSql::BLOB
|
363
363
|
@raw_statement.setBlob(position, value)
|
364
|
-
when
|
364
|
+
when Java::OracleSql::CLOB
|
365
365
|
@raw_statement.setClob(position, value)
|
366
366
|
when ActiveRecord::OracleEnhanced::Type::Raw
|
367
367
|
@raw_statement.setString(position, ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.encode_raw(value))
|
@@ -9,8 +9,9 @@ module ActiveRecord
|
|
9
9
|
blob.setBytes(1, value.to_s.to_java_bytes)
|
10
10
|
blob
|
11
11
|
when ActiveRecord::OracleEnhanced::Type::Text::Data
|
12
|
-
|
13
|
-
value.to_s
|
12
|
+
clob = Java::OracleSql::CLOB.createTemporary(@connection.raw_connection, false, Java::OracleSql::CLOB::DURATION_SESSION)
|
13
|
+
clob.setString(1, value.to_s)
|
14
|
+
clob
|
14
15
|
when Date, DateTime
|
15
16
|
Java::oracle.sql.DATE.new(value.strftime("%Y-%m-%d %H:%M:%S"))
|
16
17
|
when Time
|
@@ -1,14 +1,5 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module ConnectionAdapters
|
3
|
-
#TODO: Overriding `aliased_types` cause another database adapter behavior changes
|
4
|
-
#It should be addressed by supporting `create_table_definition`
|
5
|
-
class TableDefinition
|
6
|
-
private
|
7
|
-
def aliased_types(name, fallback)
|
8
|
-
fallback
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
3
|
module OracleEnhanced
|
13
4
|
|
14
5
|
class ForeignKeyDefinition < ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
|
@@ -1070,7 +1070,7 @@ module ActiveRecord
|
|
1070
1070
|
SQL
|
1071
1071
|
|
1072
1072
|
warn <<-WARNING.strip_heredoc if pks.count > 1
|
1073
|
-
WARNING:
|
1073
|
+
WARNING: Active Record does not support composite primary key.
|
1074
1074
|
|
1075
1075
|
#{table_name} has composite primary key. Composite primary key is ignored.
|
1076
1076
|
WARNING
|
@@ -34,55 +34,6 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
|
|
34
34
|
@conn.execute "DROP SEQUENCE test_employees_seq"
|
35
35
|
end
|
36
36
|
|
37
|
-
xit "should set DATE column type as datetime if emulate_dates_by_column_name is false" do
|
38
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
|
39
|
-
columns = @conn.columns('test_employees')
|
40
|
-
column = columns.detect{|c| c.name == "hire_date"}
|
41
|
-
expect(column.type).to eq(:datetime)
|
42
|
-
end
|
43
|
-
|
44
|
-
xit "should set DATE column type as date if column name contains '_date_' and emulate_dates_by_column_name is true" do
|
45
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
46
|
-
columns = @conn.columns('test_employees')
|
47
|
-
column = columns.detect{|c| c.name == "hire_date"}
|
48
|
-
expect(column.type).to eq(:date)
|
49
|
-
end
|
50
|
-
|
51
|
-
xit "should set DATE column type as datetime if column name does not contain '_date_' and emulate_dates_by_column_name is true" do
|
52
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
53
|
-
columns = @conn.columns('test_employees')
|
54
|
-
column = columns.detect{|c| c.name == "created_at"}
|
55
|
-
expect(column.type).to eq(:datetime)
|
56
|
-
end
|
57
|
-
|
58
|
-
xit "should set DATE column type as datetime if column name contains 'date' as part of other word and emulate_dates_by_column_name is true" do
|
59
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
60
|
-
columns = @conn.columns('test_employees')
|
61
|
-
column = columns.detect{|c| c.name == "updated_at"}
|
62
|
-
expect(column.type).to eq(:datetime)
|
63
|
-
end
|
64
|
-
|
65
|
-
xit "should return Time value from DATE column if emulate_dates_by_column_name is false" do
|
66
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
|
67
|
-
columns = @conn.columns('test_employees')
|
68
|
-
column = columns.detect{|c| c.name == "hire_date"}
|
69
|
-
expect(@conn.lookup_cast_type_from_column(column).cast(Time.now).class).to eq(Time)
|
70
|
-
end
|
71
|
-
|
72
|
-
xit "should return Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
|
73
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
74
|
-
columns = @conn.columns('test_employees')
|
75
|
-
column = columns.detect{|c| c.name == "hire_date"}
|
76
|
-
expect(@conn.lookup_cast_type_from_column(column).cast(Time.now).class).to eq(Date)
|
77
|
-
end
|
78
|
-
|
79
|
-
xit "should typecast DateTime value to Date value from DATE column if column name contains 'date' and emulate_dates_by_column_name is true" do
|
80
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
|
81
|
-
columns = @conn.columns('test_employees')
|
82
|
-
column = columns.detect{|c| c.name == "hire_date"}
|
83
|
-
expect(@conn.lookup_cast_type_from_column(column).cast(DateTime.new(1900,1,1)).class).to eq(Date)
|
84
|
-
end
|
85
|
-
|
86
37
|
describe "/ DATE values from ActiveRecord model" do
|
87
38
|
before(:each) do
|
88
39
|
# ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
|
@@ -162,16 +113,6 @@ describe "OracleEnhancedAdapter date type detection based on column names" do
|
|
162
113
|
expect(@employee.hire_date.class).to eq(Date)
|
163
114
|
end
|
164
115
|
|
165
|
-
xit "should see set_date_columns values in different connection" do
|
166
|
-
class ::TestEmployee < ActiveRecord::Base
|
167
|
-
set_date_columns :hire_date
|
168
|
-
end
|
169
|
-
# ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = false
|
170
|
-
# establish other connection
|
171
|
-
other_conn = ActiveRecord::Base.oracle_enhanced_connection(CONNECTION_PARAMS)
|
172
|
-
expect(other_conn.get_type_for_column('test_employees', 'hire_date')).to eq(:date)
|
173
|
-
end
|
174
|
-
|
175
116
|
it "should return Time value from DATE column if emulate_dates_by_column_name is true but column is defined as datetime" do
|
176
117
|
class ::TestEmployee < ActiveRecord::Base
|
177
118
|
# set_datetime_columns :hire_date
|
@@ -237,43 +178,6 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
237
178
|
@conn.execute "DROP SEQUENCE test2_employees_seq"
|
238
179
|
end
|
239
180
|
|
240
|
-
xit "should set NUMBER column type as decimal if emulate_integers_by_column_name is false" do
|
241
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
|
242
|
-
columns = @conn.columns('test2_employees')
|
243
|
-
column = columns.detect{|c| c.name == "job_id"}
|
244
|
-
expect(column.type).to eq(:decimal)
|
245
|
-
end
|
246
|
-
|
247
|
-
xit "should set NUMBER column type as integer if emulate_integers_by_column_name is true" do
|
248
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
249
|
-
columns = @conn.columns('test2_employees')
|
250
|
-
column = columns.detect{|c| c.name == "job_id"}
|
251
|
-
expect(column.type).to eq(:integer)
|
252
|
-
column = columns.detect{|c| c.name == "id"}
|
253
|
-
expect(column.type).to eq(:integer)
|
254
|
-
end
|
255
|
-
|
256
|
-
xit "should set NUMBER column type as decimal if column name does not contain 'id' and emulate_integers_by_column_name is true" do
|
257
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
258
|
-
columns = @conn.columns('test2_employees')
|
259
|
-
column = columns.detect{|c| c.name == "salary"}
|
260
|
-
expect(column.type).to eq(:decimal)
|
261
|
-
end
|
262
|
-
|
263
|
-
xit "should return BigDecimal value from NUMBER column if emulate_integers_by_column_name is false" do
|
264
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
|
265
|
-
columns = @conn.columns('test2_employees')
|
266
|
-
column = columns.detect{|c| c.name == "job_id"}
|
267
|
-
expect(@conn.lookup_cast_type_from_column(column).cast(1.0).class).to eq(BigDecimal)
|
268
|
-
end
|
269
|
-
|
270
|
-
xit "should return Fixnum value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
|
271
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
272
|
-
columns = @conn.columns('test2_employees')
|
273
|
-
column = columns.detect{|c| c.name == "job_id"}
|
274
|
-
expect(@conn.lookup_cast_type_from_column(column).cast(1.0).class).to eq(Fixnum)
|
275
|
-
end
|
276
|
-
|
277
181
|
describe "/ NUMBER values from ActiveRecord model" do
|
278
182
|
before(:each) do
|
279
183
|
class ::Test2Employee < ActiveRecord::Base
|
@@ -442,71 +346,12 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
442
346
|
end
|
443
347
|
end
|
444
348
|
|
445
|
-
xit "should set CHAR/VARCHAR2 column type as string if emulate_booleans_from_strings is false" do
|
446
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
447
|
-
columns = @conn.columns('test3_employees')
|
448
|
-
%w(has_email has_phone active_flag manager_yn).each do |col|
|
449
|
-
column = columns.detect{|c| c.name == col}
|
450
|
-
expect(column.type).to eq(:string)
|
451
|
-
end
|
452
|
-
end
|
453
|
-
|
454
|
-
xit "should set CHAR/VARCHAR2 column type as boolean if emulate_booleans_from_strings is true" do
|
455
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
456
|
-
columns = @conn.columns('test3_employees')
|
457
|
-
%w(has_email has_phone active_flag manager_yn).each do |col|
|
458
|
-
column = columns.detect{|c| c.name == col}
|
459
|
-
expect(column.type).to eq(:boolean)
|
460
|
-
end
|
461
|
-
end
|
462
|
-
|
463
|
-
xit "should set VARCHAR2 column type as string if column name does not contain 'flag' or 'yn' and emulate_booleans_from_strings is true" do
|
464
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
465
|
-
columns = @conn.columns('test3_employees')
|
466
|
-
%w(phone_number email).each do |col|
|
467
|
-
column = columns.detect{|c| c.name == col}
|
468
|
-
expect(column.type).to eq(:string)
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
|
-
xit "should return string value from VARCHAR2 boolean column if emulate_booleans_from_strings is false" do
|
473
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
474
|
-
columns = @conn.columns('test3_employees')
|
475
|
-
%w(has_email has_phone active_flag manager_yn).each do |col|
|
476
|
-
column = columns.detect{|c| c.name == col}
|
477
|
-
expect(@conn.lookup_cast_type_from_column(column).cast("Y").class).to eq(String)
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
xit "should return boolean value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
|
482
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
483
|
-
columns = @conn.columns('test3_employees')
|
484
|
-
%w(has_email has_phone active_flag manager_yn).each do |col|
|
485
|
-
column = columns.detect{|c| c.name == col}
|
486
|
-
expect(@conn.lookup_cast_type_from_column(column).cast("Y").class).to eq(TrueClass)
|
487
|
-
expect(@conn.lookup_cast_type_from_column(column).cast("N").class).to eq(FalseClass)
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
xit "should translate boolean type to VARCHAR2(1) if emulate_booleans_from_strings is true" do
|
492
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
493
|
-
expect(ActiveRecord::Base.connection.type_to_sql(
|
494
|
-
:boolean, nil, nil, nil)).to eq("VARCHAR2(1)")
|
495
|
-
end
|
496
|
-
|
497
349
|
it "should translate boolean type to NUMBER(1) if emulate_booleans_from_strings is false" do
|
498
350
|
# ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
499
351
|
expect(ActiveRecord::Base.connection.type_to_sql(
|
500
352
|
:boolean, nil, nil, nil)).to eq("NUMBER(1)")
|
501
353
|
end
|
502
354
|
|
503
|
-
xit "should get default value from VARCHAR2 boolean column if emulate_booleans_from_strings is true" do
|
504
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
505
|
-
columns = @conn.columns('test3_employees')
|
506
|
-
expect(columns.detect{|c| c.name == 'has_phone'}.default).to be_truthy
|
507
|
-
expect(columns.detect{|c| c.name == 'manager_yn'}.default).to be_falsey
|
508
|
-
end
|
509
|
-
|
510
355
|
describe "/ VARCHAR2 boolean values from ActiveRecord model" do
|
511
356
|
before(:each) do
|
512
357
|
# ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = false
|
@@ -782,21 +627,6 @@ describe "OracleEnhancedAdapter date and timestamp with different NLS date forma
|
|
782
627
|
expect(@employee.created_at_ts).to eq(@now)
|
783
628
|
end
|
784
629
|
|
785
|
-
xit "should quote Date values with TO_DATE" do
|
786
|
-
expect(@conn.quote(@today)).to eq("TO_DATE('#{@today.year}-#{"%02d" % @today.month}-#{"%02d" % @today.day}','YYYY-MM-DD HH24:MI:SS')")
|
787
|
-
end
|
788
|
-
|
789
|
-
xit "should quote Time values with TO_DATE" do
|
790
|
-
expect(@conn.quote(@now)).to eq("TO_DATE('#{@now.year}-#{"%02d" % @now.month}-#{"%02d" % @now.day} "+
|
791
|
-
"#{"%02d" % @now.hour}:#{"%02d" % @now.min}:#{"%02d" % @now.sec}','YYYY-MM-DD HH24:MI:SS')")
|
792
|
-
end
|
793
|
-
|
794
|
-
xit "should quote Time values with TO_TIMESTAMP" do
|
795
|
-
@ts = @now + 0.1
|
796
|
-
expect(@conn.quote(@ts)).to eq("TO_TIMESTAMP('#{@ts.year}-#{"%02d" % @ts.month}-#{"%02d" % @ts.day} "+
|
797
|
-
"#{"%02d" % @ts.hour}:#{"%02d" % @ts.min}:#{"%02d" % @ts.sec}:100000','YYYY-MM-DD HH24:MI:SS:FF6')")
|
798
|
-
end
|
799
|
-
|
800
630
|
end
|
801
631
|
|
802
632
|
describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
|
@@ -1493,15 +1323,6 @@ describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
|
|
1493
1323
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
1494
1324
|
end
|
1495
1325
|
|
1496
|
-
xit "should set nchar instance variable" do
|
1497
|
-
columns = @conn.columns('test_items')
|
1498
|
-
%w(nchar_column nvarchar2_column char_column varchar2_column).each do |col|
|
1499
|
-
column = columns.detect{|c| c.name == col}
|
1500
|
-
expect(column.type).to eq(:string)
|
1501
|
-
expect(column.nchar).to eq(col[0,1] == 'n' ? true : nil)
|
1502
|
-
end
|
1503
|
-
end
|
1504
|
-
|
1505
1326
|
it "should quote with N prefix" do
|
1506
1327
|
columns = @conn.columns('test_items')
|
1507
1328
|
%w(nchar_column nvarchar2_column char_column varchar2_column).each do |col|
|
@@ -225,24 +225,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
225
225
|
expect(standard_dump(ignore_tables: [ /test_posts/i ])).to match(/add_foreign_key "test_comments"/)
|
226
226
|
end
|
227
227
|
|
228
|
-
it "should include composite foreign keys" do
|
229
|
-
skip "Composite foreign keys are not supported in this version"
|
230
|
-
schema_define do
|
231
|
-
add_column :test_posts, :baz_id, :integer
|
232
|
-
add_column :test_posts, :fooz_id, :integer
|
233
|
-
|
234
|
-
execute <<-SQL
|
235
|
-
ALTER TABLE TEST_POSTS
|
236
|
-
ADD CONSTRAINT UK_FOOZ_BAZ UNIQUE (BAZ_ID,FOOZ_ID)
|
237
|
-
SQL
|
238
|
-
|
239
|
-
add_column :test_comments, :baz_id, :integer
|
240
|
-
add_column :test_comments, :fooz_id, :integer
|
241
|
-
|
242
|
-
add_foreign_key :test_comments, :test_posts, columns: ["baz_id", "fooz_id"], name: 'comments_posts_baz_fooz_fk'
|
243
|
-
end
|
244
|
-
expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts", columns: \["baz_id", "fooz_id"\], name: "comments_posts_baz_fooz_fk"/)
|
245
|
-
end
|
246
228
|
it "should include foreign keys following all tables" do
|
247
229
|
# if foreign keys preceed declaration of all tables
|
248
230
|
# it can cause problems when using db:test rake tasks
|
@@ -733,52 +733,6 @@ end
|
|
733
733
|
expect(TestComment.find_by_id(c.id).test_post_id).to be_nil
|
734
734
|
end
|
735
735
|
|
736
|
-
it "should add a composite foreign key" do
|
737
|
-
skip "Composite foreign keys are not supported in this version"
|
738
|
-
schema_define do
|
739
|
-
add_column :test_posts, :baz_id, :integer
|
740
|
-
add_column :test_posts, :fooz_id, :integer
|
741
|
-
|
742
|
-
execute <<-SQL
|
743
|
-
ALTER TABLE TEST_POSTS
|
744
|
-
ADD CONSTRAINT UK_FOOZ_BAZ UNIQUE (BAZ_ID,FOOZ_ID)
|
745
|
-
SQL
|
746
|
-
|
747
|
-
add_column :test_comments, :baz_id, :integer
|
748
|
-
add_column :test_comments, :fooz_id, :integer
|
749
|
-
|
750
|
-
add_foreign_key :test_comments, :test_posts, :columns => ["baz_id", "fooz_id"]
|
751
|
-
end
|
752
|
-
|
753
|
-
expect do
|
754
|
-
TestComment.create(:body => "test", :fooz_id => 1, :baz_id => 1)
|
755
|
-
end.to raise_error() {|e| expect(e.message).to match(
|
756
|
-
/ORA-02291.*\.TES_COM_BAZ_ID_FOO_ID_FK/
|
757
|
-
)}
|
758
|
-
end
|
759
|
-
|
760
|
-
it "should add a composite foreign key with name" do
|
761
|
-
skip "Composite foreign keys are not supported in this version"
|
762
|
-
schema_define do
|
763
|
-
add_column :test_posts, :baz_id, :integer
|
764
|
-
add_column :test_posts, :fooz_id, :integer
|
765
|
-
|
766
|
-
execute <<-SQL
|
767
|
-
ALTER TABLE TEST_POSTS
|
768
|
-
ADD CONSTRAINT UK_FOOZ_BAZ UNIQUE (BAZ_ID,FOOZ_ID)
|
769
|
-
SQL
|
770
|
-
|
771
|
-
add_column :test_comments, :baz_id, :integer
|
772
|
-
add_column :test_comments, :fooz_id, :integer
|
773
|
-
|
774
|
-
add_foreign_key :test_comments, :test_posts, :columns => ["baz_id", "fooz_id"], :name => 'comments_posts_baz_fooz_fk'
|
775
|
-
end
|
776
|
-
|
777
|
-
expect do
|
778
|
-
TestComment.create(:body => "test", :baz_id => 1, :fooz_id => 1)
|
779
|
-
end.to raise_error() {|e| expect(e.message).to match(/ORA-02291.*\.COMMENTS_POSTS_BAZ_FOOZ_FK/)}
|
780
|
-
end
|
781
|
-
|
782
736
|
it "should remove foreign key by table name" do
|
783
737
|
schema_define do
|
784
738
|
add_foreign_key :test_comments, :test_posts
|
@@ -91,29 +91,6 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
91
91
|
expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\)/i)
|
92
92
|
end
|
93
93
|
|
94
|
-
it "should dump composite foreign keys" do
|
95
|
-
skip "Composite foreign keys are not supported in this version"
|
96
|
-
@conn.add_column :foos, :fooz_id, :integer
|
97
|
-
@conn.add_column :foos, :baz_id, :integer
|
98
|
-
|
99
|
-
@conn.execute <<-SQL
|
100
|
-
ALTER TABLE FOOS
|
101
|
-
ADD CONSTRAINT UK_FOOZ_BAZ UNIQUE (BAZ_ID,FOOZ_ID)
|
102
|
-
SQL
|
103
|
-
|
104
|
-
@conn.add_column :test_posts, :fooz_id, :integer
|
105
|
-
@conn.add_column :test_posts, :baz_id, :integer
|
106
|
-
|
107
|
-
@conn.execute <<-SQL
|
108
|
-
ALTER TABLE TEST_POSTS
|
109
|
-
ADD CONSTRAINT fk_test_post_fooz_baz FOREIGN KEY (baz_id,fooz_id) REFERENCES foos(baz_id,fooz_id)
|
110
|
-
SQL
|
111
|
-
|
112
|
-
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
113
|
-
expect(dump.split('\n').length).to eq(1)
|
114
|
-
expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_FOOZ_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\,\"?FOOZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\,\"?FOOZ_ID\"?\)/i)
|
115
|
-
end
|
116
|
-
|
117
94
|
it "should not error when no foreign keys are present" do
|
118
95
|
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
119
96
|
expect(dump.split('\n').length).to eq(0)
|
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.beta2
|
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-07-
|
11
|
+
date: 2016-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 7.1.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 7.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: ruby-plsql
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
152
|
requirements:
|
153
153
|
- - ">="
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
155
|
+
version: 2.2.2
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - ">="
|