activerecord-oracle_enhanced-adapter 1.7.4 → 1.7.5
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 +20 -0
- data/README.md +6 -0
- data/RUNNING_TESTS.md +1 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +3 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +4 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +17 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +13 -3
- data/lib/activerecord-oracle_enhanced-adapter.rb +14 -12
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +17 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +47 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbee32f7aef3920b9639b3f19172e4aeae188b8a
|
4
|
+
data.tar.gz: d5d3f5ae44a57a8e41d967a580c4d9374bee1502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf3c243fccd4ec5457803b12ab1e9466c5fbc2f60733ad8ed909ba4159071bb5c0bae6b74b9cd0b961a3f719ab14cdab73cca1a581338247cd30fb6ced3c187f
|
7
|
+
data.tar.gz: 08b07678d01763e02d12ebef563c0579afe4e9691a2ce49f7bcdf78be09b43e9b3945ee229cb4759e4efffd19c188f7ac411f0c51a70794cb583693b4022a625
|
data/History.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 1.7.5 / 2016-11-06
|
2
|
+
|
3
|
+
* Changes and bug fixes
|
4
|
+
|
5
|
+
* Multi insert is not supported [#1016]
|
6
|
+
* Use `default_timezone = :local` to handle `TIMESTAMP WITH LOCAL TIME ZONE` [#1001, #1019]
|
7
|
+
* Address Rails 5 : custom methods for create record when exception is raised in `after_create` callback fails [#944, #1023]
|
8
|
+
* Using the gem in non-rails apps [#1026]
|
9
|
+
* Support connection strings in `DATABASE_URL1 [#1032, #1035]
|
10
|
+
* Rebuild primary key index to `default_tablespaces[:index]` [#1028]
|
11
|
+
* Address `Java::JavaSql::SQLException: Missing IN or OUT parameter at index:: 3:` [#1030, #1033]
|
12
|
+
|
13
|
+
* Known issues
|
14
|
+
|
15
|
+
- Only with JRuby
|
16
|
+
* Rails 5 : explain should explain query with binds got Java::JavaSql::SQLException: Invalid column index [#908]
|
17
|
+
* Workaround: execute explain without bind or use CRuby
|
18
|
+
- CRuby and JRuby
|
19
|
+
* Rails 5 : specs need update to emulate_booleans_from_strings [#942]
|
20
|
+
|
1
21
|
## 1.7.4 / 2016-10-14
|
2
22
|
|
3
23
|
* Changes and bug fixes
|
data/README.md
CHANGED
@@ -200,6 +200,12 @@ environment variable, note that the adapter name uses a dash instead of an under
|
|
200
200
|
DATABASE_URL=oracle-enhanced://localhost/XE
|
201
201
|
```
|
202
202
|
|
203
|
+
You can also specify a connection string via the `DATABASE_URL`, as long as it doesn't have any whitespace:
|
204
|
+
|
205
|
+
```bash
|
206
|
+
DATABASE_URL=oracle-enhanced://user:secret@connection-string/(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xe)))
|
207
|
+
```
|
208
|
+
|
203
209
|
If you deploy JRuby on Rails application in Java application server that supports JNDI connections then you can specify JNDI connection as well:
|
204
210
|
|
205
211
|
```yml
|
data/RUNNING_TESTS.md
CHANGED
@@ -75,7 +75,7 @@ Running tests
|
|
75
75
|
bundle install
|
76
76
|
|
77
77
|
* Configure database credentials in one of two ways:
|
78
|
-
* copy spec/spec_config.yaml.template to spec/
|
78
|
+
* copy spec/spec_config.yaml.template to spec/spec_config.yaml and modify as needed
|
79
79
|
* set required environment variables (see DATABASE_NAME in spec_helper.rb)
|
80
80
|
|
81
81
|
* Run tests with
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.5
|
@@ -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.
|
3
|
+
s.version = "1.7.5"
|
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-
|
9
|
+
s.date = %q{2016-11-06}
|
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
|
}
|
@@ -109,8 +109,9 @@ module ActiveRecord
|
|
109
109
|
host, port = config[:host], config[:port]
|
110
110
|
privilege = config[:privilege] && config[:privilege].to_s
|
111
111
|
|
112
|
-
# connection using TNS alias
|
113
|
-
|
112
|
+
# connection using TNS alias, or connection-string from DATABASE_URL
|
113
|
+
using_tns_alias = !host && !config[:url] && ENV['TNS_ADMIN']
|
114
|
+
if database && (using_tns_alias || host == 'connection-string')
|
114
115
|
url = "jdbc:oracle:thin:@#{database}"
|
115
116
|
else
|
116
117
|
unless database.match(/^(\:|\/)/)
|
@@ -332,8 +332,11 @@ module ActiveRecord
|
|
332
332
|
# get session time_zone from configuration or from TZ environment variable
|
333
333
|
time_zone = config[:time_zone] || ENV['TZ']
|
334
334
|
|
335
|
+
# using a connection string via DATABASE_URL
|
336
|
+
connection_string = if host == 'connection-string'
|
337
|
+
database
|
335
338
|
# connection using host, port and database name
|
336
|
-
|
339
|
+
elsif host || port
|
337
340
|
host ||= 'localhost'
|
338
341
|
host = "[#{host}]" if host =~ /^[^\[].*:/ # IPv6
|
339
342
|
port ||= 1521
|
@@ -344,7 +347,6 @@ module ActiveRecord
|
|
344
347
|
else
|
345
348
|
database
|
346
349
|
end
|
347
|
-
|
348
350
|
conn = OCI8.new username, password, connection_string, privilege
|
349
351
|
conn.autocommit = true
|
350
352
|
conn.non_blocking = true if async
|
@@ -85,6 +85,7 @@ module ActiveRecord
|
|
85
85
|
end
|
86
86
|
td.indexes.each { |c,o| add_index table_name, c, o }
|
87
87
|
|
88
|
+
rebuild_primary_key_index_to_default_tablespace(table_name, options)
|
88
89
|
end
|
89
90
|
|
90
91
|
def create_table_definition(*args)
|
@@ -504,6 +505,22 @@ module ActiveRecord
|
|
504
505
|
"#{table_name.to_s[0,table_name_length-4]}_pkt"
|
505
506
|
end
|
506
507
|
|
508
|
+
def rebuild_primary_key_index_to_default_tablespace(table_name, options)
|
509
|
+
tablespace = default_tablespace_for(:index)
|
510
|
+
|
511
|
+
return unless tablespace
|
512
|
+
|
513
|
+
index_name = Base.connection.select_value(
|
514
|
+
"SELECT index_name FROM all_constraints
|
515
|
+
WHERE table_name = #{quote(table_name.upcase)}
|
516
|
+
AND constraint_type = 'P'
|
517
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')")
|
518
|
+
|
519
|
+
return unless index_name
|
520
|
+
|
521
|
+
execute("ALTER INDEX #{quote_column_name(index_name)} REBUILD TABLESPACE #{tablespace}")
|
522
|
+
end
|
523
|
+
|
507
524
|
end
|
508
525
|
end
|
509
526
|
end
|
@@ -483,6 +483,10 @@ module ActiveRecord
|
|
483
483
|
true
|
484
484
|
end
|
485
485
|
|
486
|
+
def supports_multi_insert?
|
487
|
+
false
|
488
|
+
end
|
489
|
+
|
486
490
|
#:stopdoc:
|
487
491
|
DEFAULT_NLS_PARAMETERS = {
|
488
492
|
:nls_calendar => nil,
|
@@ -1161,11 +1165,17 @@ module ActiveRecord
|
|
1161
1165
|
offset: nil
|
1162
1166
|
) # :nodoc:
|
1163
1167
|
result = from_clause + join_clause + where_clause + having_clause
|
1164
|
-
if offset
|
1168
|
+
if RUBY_ENGINE == 'jruby' && !supports_fetch_first_n_rows_and_offset? && offset && limit
|
1165
1169
|
result << offset
|
1166
|
-
end
|
1167
|
-
if limit
|
1168
1170
|
result << limit
|
1171
|
+
result << offset
|
1172
|
+
else
|
1173
|
+
if offset
|
1174
|
+
result << offset
|
1175
|
+
end
|
1176
|
+
if limit
|
1177
|
+
result << limit
|
1178
|
+
end
|
1169
1179
|
end
|
1170
1180
|
result
|
1171
1181
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
if defined?(Rails)
|
2
|
+
module ActiveRecord
|
3
|
+
module ConnectionAdapters
|
4
|
+
class OracleEnhancedRailtie < ::Rails::Railtie
|
5
|
+
rake_tasks do
|
6
|
+
load 'active_record/connection_adapters/oracle_enhanced/database_tasks.rb'
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
ActiveSupport.on_load(:active_record) do
|
10
|
+
require 'active_record/connection_adapters/oracle_enhanced_adapter'
|
11
|
+
|
12
|
+
# Cache column descriptions between requests in test and production environments
|
13
|
+
if Rails.env.test? || Rails.env.production?
|
14
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = true
|
15
|
+
end
|
10
16
|
|
11
|
-
# Cache column descriptions between requests in test and production environments
|
12
|
-
if Rails.env.test? || Rails.env.production?
|
13
|
-
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.cache_columns = true
|
14
17
|
end
|
15
18
|
|
16
19
|
end
|
17
|
-
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -137,6 +137,23 @@ describe "OracleEnhancedConnection" do
|
|
137
137
|
|
138
138
|
end
|
139
139
|
|
140
|
+
describe 'with host="connection-string"' do
|
141
|
+
let(:username) { CONNECTION_PARAMS[:username] }
|
142
|
+
let(:password) { CONNECTION_PARAMS[:password] }
|
143
|
+
let(:connection_string) { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=#{DATABASE_HOST})(PORT=#{DATABASE_PORT})))(CONNECT_DATA=(SERVICE_NAME=#{DATABASE_NAME})))" }
|
144
|
+
let(:params) { { username: username, password: password, host: 'connection-string', database: connection_string } }
|
145
|
+
|
146
|
+
it 'uses the database param as the connection string' do
|
147
|
+
if ORACLE_ENHANCED_CONNECTION == :jdbc
|
148
|
+
expect(java.sql.DriverManager).to receive(:getConnection).with("jdbc:oracle:thin:@#{connection_string}", anything).and_call_original
|
149
|
+
else
|
150
|
+
expect(OCI8).to receive(:new).with(username, password, connection_string, nil).and_call_original
|
151
|
+
end
|
152
|
+
conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
|
153
|
+
expect(conn).to be_active
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
140
157
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
141
158
|
|
142
159
|
describe "create JDBC connection" do
|
@@ -475,7 +475,8 @@ end
|
|
475
475
|
|
476
476
|
describe "OracleEnhancedAdapter timestamp with timezone support" do
|
477
477
|
before(:all) do
|
478
|
-
ActiveRecord::Base.
|
478
|
+
ActiveRecord::Base.default_timezone = :local
|
479
|
+
ActiveRecord::Base.establish_connection(CONNECTION_WITH_TIMEZONE_PARAMS)
|
479
480
|
@conn = ActiveRecord::Base.connection
|
480
481
|
@conn.execute <<-SQL
|
481
482
|
CREATE TABLE test_employees (
|
@@ -504,6 +505,7 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
|
|
504
505
|
after(:all) do
|
505
506
|
@conn.execute "DROP TABLE test_employees"
|
506
507
|
@conn.execute "DROP SEQUENCE test_employees_seq"
|
508
|
+
ActiveRecord::Base.default_timezone = :utc
|
507
509
|
end
|
508
510
|
|
509
511
|
it "should set TIMESTAMP columns type as datetime" do
|
@@ -518,13 +520,11 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
|
|
518
520
|
class ::TestEmployee < ActiveRecord::Base
|
519
521
|
self.primary_key = "employee_id"
|
520
522
|
end
|
521
|
-
ActiveRecord::Base.default_timezone = :local
|
522
523
|
end
|
523
524
|
|
524
525
|
after(:all) do
|
525
526
|
Object.send(:remove_const, "TestEmployee")
|
526
527
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
527
|
-
ActiveRecord::Base.default_timezone = :utc
|
528
528
|
end
|
529
529
|
|
530
530
|
it "should return Time value from TIMESTAMP columns" do
|
@@ -186,7 +186,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
186
186
|
expect {
|
187
187
|
@employee.save
|
188
188
|
}.to raise_error("Make the transaction rollback")
|
189
|
-
expect(@employee.
|
189
|
+
expect(@employee.new_record?).to be_truthy
|
190
190
|
expect(TestEmployee.count).to eq(employees_count)
|
191
191
|
end
|
192
192
|
|
@@ -804,6 +804,53 @@ end
|
|
804
804
|
end
|
805
805
|
end
|
806
806
|
|
807
|
+
describe "primary key in table definition" do
|
808
|
+
before do
|
809
|
+
@conn = ActiveRecord::Base.connection
|
810
|
+
|
811
|
+
class ::TestPost < ActiveRecord::Base
|
812
|
+
end
|
813
|
+
end
|
814
|
+
|
815
|
+
it 'should use default tablespace for primary key' do
|
816
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:index] = nil
|
817
|
+
schema_define do
|
818
|
+
create_table :test_posts, :force => true
|
819
|
+
end
|
820
|
+
|
821
|
+
index_name = @conn.select_value(
|
822
|
+
"SELECT index_name FROM all_constraints
|
823
|
+
WHERE table_name = 'TEST_POSTS'
|
824
|
+
AND constraint_type = 'P'
|
825
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')")
|
826
|
+
|
827
|
+
expect(TestPost.connection.select_value("SELECT tablespace_name FROM user_indexes WHERE index_name = '#{index_name}'")).to eq('USERS')
|
828
|
+
end
|
829
|
+
|
830
|
+
it 'should use non default tablespace for primary key' do
|
831
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:index] = DATABASE_NON_DEFAULT_TABLESPACE
|
832
|
+
schema_define do
|
833
|
+
create_table :test_posts, :force => true
|
834
|
+
end
|
835
|
+
|
836
|
+
index_name = @conn.select_value(
|
837
|
+
"SELECT index_name FROM all_constraints
|
838
|
+
WHERE table_name = 'TEST_POSTS'
|
839
|
+
AND constraint_type = 'P'
|
840
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')")
|
841
|
+
|
842
|
+
expect(TestPost.connection.select_value("SELECT tablespace_name FROM user_indexes WHERE index_name = '#{index_name}'")).to eq(DATABASE_NON_DEFAULT_TABLESPACE)
|
843
|
+
end
|
844
|
+
|
845
|
+
after do
|
846
|
+
Object.send(:remove_const, "TestPost")
|
847
|
+
schema_define do
|
848
|
+
drop_table :test_posts rescue nil
|
849
|
+
end
|
850
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:index] = nil
|
851
|
+
end
|
852
|
+
end
|
853
|
+
|
807
854
|
describe "foreign key in table definition" do
|
808
855
|
before(:each) do
|
809
856
|
schema_define do
|
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.
|
4
|
+
version: 1.7.5
|
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-
|
11
|
+
date: 2016-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.5.1
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Oracle enhanced adapter for ActiveRecord
|