activerecord-oracle_enhanced-adapter 1.6.7 → 1.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +39 -0
- data/.travis/oracle/download.sh +14 -0
- data/.travis/oracle/install.sh +31 -0
- data/.travis/setup_accounts.sh +9 -0
- data/Gemfile +1 -1
- data/History.md +12 -0
- data/README.md +8 -0
- data/RUNNING_TESTS.md +1 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +3 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +6 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +18 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +55 -8
- 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 +12 -12
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +47 -0
- data/spec/support/alter_system_user_password.sql +2 -0
- data/spec/support/create_oracle_enhanced_users.sql +31 -0
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0fbbf8088124f049e32170d6d45e369ee9167a2
|
4
|
+
data.tar.gz: a601d05f95b7763d9688aa06a5aedc8eab3ab841
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa62056e503ced618cf72c9344712ba4b751a8bdcecce0dea8573ee8755fa7a63837e1f368a33f296a3a2241f3c63ff1a65bff69274d55030f95c9703dc0e0ea
|
7
|
+
data.tar.gz: d16f49fd9c02333cf25e501c75f5bcf353e876bc0c6e2209f4c58615168182e8abcf72f7255b7db7fff0098de2766629a1b8a701ad80e7c913ed33504bdce5dd
|
data/.travis.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
sudo: required
|
2
|
+
|
3
|
+
env:
|
4
|
+
global:
|
5
|
+
- ORACLE_COOKIE=sqldev
|
6
|
+
- ORACLE_FILE=oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip
|
7
|
+
- ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
|
8
|
+
- TNS_ADMIN=$ORACLE_HOME/network/admin
|
9
|
+
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
|
10
|
+
- ORACLE_BASE=/u01/app/oracle
|
11
|
+
- LD_LIBRARY_PATH=$ORACLE_HOME/lib
|
12
|
+
- PATH=$PATH:$ORACLE_HOME/jdbc/lib
|
13
|
+
- DATABASE_VERSION=11.2.0.2
|
14
|
+
- ORACLE_SID=XE
|
15
|
+
- DATABASE_NAME=XE
|
16
|
+
- ORA_SDTZ='Europe/Riga' #Needed as a client parameter
|
17
|
+
- TZ='Europe/Riga' #Needed as a DB Server parameter
|
18
|
+
- "JRUBY_OPTS='--debug --dev -J-Xmx1024M'"
|
19
|
+
|
20
|
+
before_install:
|
21
|
+
- chmod +x .travis/oracle/download.sh
|
22
|
+
- chmod +x .travis/oracle/install.sh
|
23
|
+
- chmod +x .travis/setup_accounts.sh
|
24
|
+
|
25
|
+
install:
|
26
|
+
- .travis/oracle/download.sh
|
27
|
+
- .travis/oracle/install.sh
|
28
|
+
- .travis/setup_accounts.sh
|
29
|
+
- bundle install
|
30
|
+
|
31
|
+
language: ruby
|
32
|
+
rvm:
|
33
|
+
- 2.2.6
|
34
|
+
- 2.3.3
|
35
|
+
- 2.4.0
|
36
|
+
- jruby-9.1.8.0
|
37
|
+
|
38
|
+
notifications:
|
39
|
+
email: false
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
cd "$(dirname "$(readlink -f "$0")")"
|
4
|
+
|
5
|
+
deb_file=oracle-xe_11.2.0-1.0_amd64.deb
|
6
|
+
|
7
|
+
git clone https://github.com/wnameless/docker-oracle-xe-11g.git
|
8
|
+
|
9
|
+
cd docker-oracle-xe-11g/assets &&
|
10
|
+
cat "${deb_file}aa" "${deb_file}ab" "${deb_file}ac" > "${deb_file}"
|
11
|
+
|
12
|
+
pwd
|
13
|
+
|
14
|
+
ls -lAh "${deb_file}"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
[ -n "$ORACLE_FILE" ] || { echo "Missing ORACLE_FILE environment variable!"; exit 1; }
|
4
|
+
[ -n "$ORACLE_HOME" ] || { echo "Missing ORACLE_HOME environment variable!"; exit 1; }
|
5
|
+
|
6
|
+
cd "$(dirname "$(readlink -f "$0")")"
|
7
|
+
|
8
|
+
ORACLE_DEB=docker-oracle-xe-11g/assets/oracle-xe_11.2.0-1.0_amd64.deb
|
9
|
+
|
10
|
+
sudo apt-get -qq update
|
11
|
+
sudo apt-get --no-install-recommends -qq install bc libaio1
|
12
|
+
|
13
|
+
df -B1 /dev/shm | awk 'END { if ($1 != "shmfs" && $1 != "tmpfs" || $2 < 2147483648) exit 1 }' ||
|
14
|
+
( sudo rm -r /dev/shm && sudo mkdir /dev/shm && sudo mount -t tmpfs shmfs -o size=2G /dev/shm )
|
15
|
+
|
16
|
+
test -f /sbin/chkconfig ||
|
17
|
+
( echo '#!/bin/sh' | sudo tee /sbin/chkconfig > /dev/null && sudo chmod u+x /sbin/chkconfig )
|
18
|
+
|
19
|
+
test -d /var/lock/subsys || sudo mkdir /var/lock/subsys
|
20
|
+
|
21
|
+
sudo dpkg -i "${ORACLE_DEB}"
|
22
|
+
|
23
|
+
echo 'OS_AUTHENT_PREFIX=""' | sudo tee -a "$ORACLE_HOME/config/scripts/init.ora" > /dev/null
|
24
|
+
sudo usermod -aG dba $USER
|
25
|
+
|
26
|
+
( echo ; echo ; echo travis ; echo travis ; echo n ) | sudo AWK='/usr/bin/awk' /etc/init.d/oracle-xe configure
|
27
|
+
|
28
|
+
"$ORACLE_HOME/bin/sqlplus" -L -S / AS SYSDBA <<SQL
|
29
|
+
CREATE USER $USER IDENTIFIED EXTERNALLY;
|
30
|
+
GRANT CONNECT, RESOURCE TO $USER;
|
31
|
+
SQL
|
data/Gemfile
CHANGED
data/History.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 1.6.8 / 2017-03-18
|
2
|
+
|
3
|
+
* Changes and bug fixes since 1.6.7
|
4
|
+
* Better fix to support "Relation#count does not support finder options anymore in Rails [#787, #788]
|
5
|
+
* Run Oracle enhanced adapter unit tests using Travis CI [#789]
|
6
|
+
* Upgrade travis-oracle to Version 2.0.1 [#903]
|
7
|
+
* NoMethodError: undefined method `write' for nil:NilClass for serialized column [#798, #1004]
|
8
|
+
* Support connection strings in `DATABASE_URL` [#1036]
|
9
|
+
* Rebuild primary key index to default_tablespaces[:index] [#1037]
|
10
|
+
* Use docker oracle xe 11g for release16 branch [#1238]
|
11
|
+
* Fix deprecated warnings in Ruby 2.4.0+ [#1237]
|
12
|
+
|
1
13
|
## 1.6.7 / 2016-03-08
|
2
14
|
|
3
15
|
* Changes and bug fixes since 1.6.6
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/rsim/oracle-enhanced.svg?branch=master)](https://travis-ci.org/rsim/oracle-enhanced)
|
2
|
+
|
1
3
|
activerecord-oracle_enhanced-adapter
|
2
4
|
====================================
|
3
5
|
|
@@ -189,6 +191,12 @@ environment variable, note that the adapter name uses a dash instead of an under
|
|
189
191
|
DATABASE_URL=oracle-enhanced://localhost/XE
|
190
192
|
```
|
191
193
|
|
194
|
+
You can also specify a connection string via the `DATABASE_URL`, as long as it doesn't have any whitespace:
|
195
|
+
|
196
|
+
```bash
|
197
|
+
DATABASE_URL=oracle-enhanced://user:secret@connection-string/(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=xe)))
|
198
|
+
```
|
199
|
+
|
192
200
|
If you deploy JRuby on Rails application in Java application server that supports JNDI connections then you can specify JNDI connection as well:
|
193
201
|
|
194
202
|
```yml
|
data/RUNNING_TESTS.md
CHANGED
@@ -42,7 +42,7 @@ Running tests
|
|
42
42
|
bundle install
|
43
43
|
|
44
44
|
* Configure database credentials in one of two ways:
|
45
|
-
* copy spec/spec_config.yaml.template to spec/
|
45
|
+
* copy spec/spec_config.yaml.template to spec/spec_config.yaml and modify as needed
|
46
46
|
* set required environment variables (see DATABASE_NAME in spec_helper.rb)
|
47
47
|
|
48
48
|
* Run tests with
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.8
|
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{activerecord-oracle_enhanced-adapter}
|
8
|
-
s.version = "1.6.
|
8
|
+
s.version = "1.6.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.license = 'MIT'
|
12
12
|
s.authors = [%q{Raimonds Simanovskis}]
|
13
|
-
s.date = %q{
|
13
|
+
s.date = %q{2017-03-18}
|
14
14
|
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
15
15
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
16
16
|
}
|
@@ -130,4 +130,3 @@ This adapter is superset of original ActiveRecord Oracle adapter.
|
|
130
130
|
s.add_dependency(%q<ruby-oci8>, [">= 2.0.4"])
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
@@ -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(/^(\:|\/)/)
|
@@ -239,12 +239,12 @@ module ActiveRecord
|
|
239
239
|
|
240
240
|
def typecast_result_value(value, get_lob_value)
|
241
241
|
case value
|
242
|
-
when
|
242
|
+
when Integer
|
243
243
|
value
|
244
244
|
when String
|
245
245
|
value
|
246
246
|
when Float, BigDecimal
|
247
|
-
# return
|
247
|
+
# return Integer if value is integer (to avoid issues with _before_type_cast values for id attributes)
|
248
248
|
value == (v_to_i = value.to_i) ? v_to_i : value
|
249
249
|
when OraNumber
|
250
250
|
# change OraNumber value (returned in early versions of ruby-oci8 2.0.x) to BigDecimal
|
@@ -317,8 +317,11 @@ module ActiveRecord
|
|
317
317
|
# get session time_zone from configuration or from TZ environment variable
|
318
318
|
time_zone = config[:time_zone] || ENV['TZ']
|
319
319
|
|
320
|
+
# using a connection string via DATABASE_URL
|
321
|
+
connection_string = if host == 'connection-string'
|
322
|
+
database
|
320
323
|
# connection using host, port and database name
|
321
|
-
|
324
|
+
elsif host || port
|
322
325
|
host ||= 'localhost'
|
323
326
|
host = "[#{host}]" if host =~ /^[^\[].*:/ # IPv6
|
324
327
|
port ||= 1521
|
@@ -329,7 +332,6 @@ module ActiveRecord
|
|
329
332
|
else
|
330
333
|
database
|
331
334
|
end
|
332
|
-
|
333
335
|
conn = OCI8.new username, password, connection_string, privilege
|
334
336
|
conn.autocommit = true
|
335
337
|
conn.non_blocking = true if async
|
@@ -92,6 +92,8 @@ module ActiveRecord
|
|
92
92
|
td.foreign_keys.each do |other_table_name, foreign_key_options|
|
93
93
|
add_foreign_key(table_name, other_table_name, foreign_key_options)
|
94
94
|
end
|
95
|
+
|
96
|
+
rebuild_primary_key_index_to_default_tablespace(table_name, options)
|
95
97
|
end
|
96
98
|
|
97
99
|
def create_table_definition(name, temporary, options)
|
@@ -538,6 +540,22 @@ module ActiveRecord
|
|
538
540
|
"#{table_name.to_s[0,table_name_length-4]}_pkt"
|
539
541
|
end
|
540
542
|
|
543
|
+
def rebuild_primary_key_index_to_default_tablespace(table_name, options)
|
544
|
+
tablespace = default_tablespace_for(:index)
|
545
|
+
|
546
|
+
return unless tablespace
|
547
|
+
|
548
|
+
index_name = Base.connection.select_value(
|
549
|
+
"SELECT index_name FROM all_constraints
|
550
|
+
WHERE table_name = #{quote(table_name.upcase)}
|
551
|
+
AND constraint_type = 'P'
|
552
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')")
|
553
|
+
|
554
|
+
return unless index_name
|
555
|
+
|
556
|
+
execute("ALTER INDEX #{quote_column_name(index_name)} REBUILD TABLESPACE #{tablespace}")
|
557
|
+
end
|
558
|
+
|
541
559
|
end
|
542
560
|
end
|
543
561
|
end
|
@@ -825,7 +825,7 @@ module ActiveRecord
|
|
825
825
|
columns.each do |col|
|
826
826
|
value = attributes[col.name]
|
827
827
|
# changed sequence of next two lines - should check if value is nil before converting to yaml
|
828
|
-
next if value.
|
828
|
+
next if value.blank?
|
829
829
|
value = col.cast_type.type_cast_for_database(value)
|
830
830
|
uncached do
|
831
831
|
sql = is_with_cpk ? "SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{klass.composite_where_clause(id)} FOR UPDATE" :
|
@@ -1079,7 +1079,7 @@ module ActiveRecord
|
|
1079
1079
|
end
|
1080
1080
|
|
1081
1081
|
# TODO: Consider to extract another method such as `get_cast_type`
|
1082
|
-
case row['sql_type']
|
1082
|
+
case row['sql_type']
|
1083
1083
|
when /decimal|numeric|number/i
|
1084
1084
|
if get_type_for_column(table_name, oracle_downcase(row['name'])) == :integer
|
1085
1085
|
cast_type = ActiveRecord::OracleEnhanced::Type::Integer.new
|
@@ -30,7 +30,7 @@ describe "OracleEnhancedAdapter establish connection" do
|
|
30
30
|
ActiveRecord::Base.connection.reconnect!
|
31
31
|
ActiveRecord::Base.connection.should be_active
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "OracleEnhancedAdapter" do
|
@@ -40,7 +40,7 @@ describe "OracleEnhancedAdapter" do
|
|
40
40
|
before(:all) do
|
41
41
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
describe "ignore specified table columns" do
|
45
45
|
before(:all) do
|
46
46
|
@conn = ActiveRecord::Base.connection
|
@@ -278,7 +278,7 @@ describe "OracleEnhancedAdapter" do
|
|
278
278
|
end
|
279
279
|
|
280
280
|
it "should execute correct SQL COUNT DISTINCT statement" do
|
281
|
-
lambda { TestEmployee.count(:employee_id
|
281
|
+
lambda { TestEmployee.distinct.count(:employee_id) }.should_not raise_error
|
282
282
|
end
|
283
283
|
|
284
284
|
end
|
@@ -377,19 +377,19 @@ describe "OracleEnhancedAdapter" do
|
|
377
377
|
@adapter.valid_table_name?("aBc").should be false
|
378
378
|
@adapter.valid_table_name?("abC").should be false
|
379
379
|
end
|
380
|
-
|
380
|
+
|
381
381
|
it "should not be valid for names > 30 characters" do
|
382
382
|
@adapter.valid_table_name?("a" * 31).should be false
|
383
383
|
end
|
384
|
-
|
384
|
+
|
385
385
|
it "should not be valid for schema names > 30 characters" do
|
386
386
|
@adapter.valid_table_name?(("a" * 31) + ".validname").should be false
|
387
387
|
end
|
388
|
-
|
388
|
+
|
389
389
|
it "should not be valid for database links > 128 characters" do
|
390
390
|
@adapter.valid_table_name?("name@" + "a" * 129).should be false
|
391
391
|
end
|
392
|
-
|
392
|
+
|
393
393
|
it "should not be valid for names that do not begin with alphabetic characters" do
|
394
394
|
@adapter.valid_table_name?("1abc").should be false
|
395
395
|
@adapter.valid_table_name?("_abc").should be false
|
@@ -457,7 +457,7 @@ describe "OracleEnhancedAdapter" do
|
|
457
457
|
|
458
458
|
cc = CamelCase.create!(:name => "Foo", :foo => 2)
|
459
459
|
cc.id.should_not be_nil
|
460
|
-
|
460
|
+
|
461
461
|
@conn.tables.should include("CamelCase")
|
462
462
|
end
|
463
463
|
|
@@ -745,4 +745,51 @@ describe "OracleEnhancedAdapter" do
|
|
745
745
|
expect(@employee.order(:sort_order).offset(4).first.first_name.should).to eq("Natasha")
|
746
746
|
end
|
747
747
|
end
|
748
|
+
|
749
|
+
describe 'serialized column' do
|
750
|
+
|
751
|
+
before(:all) do
|
752
|
+
schema_define do
|
753
|
+
create_table :test_serialized_columns do |t|
|
754
|
+
t.text :serialized
|
755
|
+
end
|
756
|
+
end
|
757
|
+
class ::TestSerializedColumn < ActiveRecord::Base
|
758
|
+
serialize :serialized, Array
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
762
|
+
after(:all) do
|
763
|
+
schema_define do
|
764
|
+
drop_table :test_serialized_columns
|
765
|
+
end
|
766
|
+
Object.send(:remove_const, 'TestSerializedColumn')
|
767
|
+
ActiveRecord::Base.table_name_prefix = nil
|
768
|
+
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
769
|
+
end
|
770
|
+
|
771
|
+
before(:each) do
|
772
|
+
set_logger
|
773
|
+
end
|
774
|
+
|
775
|
+
after(:each) do
|
776
|
+
clear_logger
|
777
|
+
end
|
778
|
+
|
779
|
+
it 'should serialize' do
|
780
|
+
new_value = 'new_value'
|
781
|
+
serialized_column = TestSerializedColumn.new
|
782
|
+
|
783
|
+
expect(serialized_column.serialized.should).to eq([])
|
784
|
+
serialized_column.serialized << new_value
|
785
|
+
expect(serialized_column.serialized.should).to eq([new_value])
|
786
|
+
serialized_column.save
|
787
|
+
expect(serialized_column.save!.should).to eq(true)
|
788
|
+
|
789
|
+
serialized_column.reload
|
790
|
+
expect(serialized_column.serialized.should).to eq([new_value])
|
791
|
+
serialized_column.serialized = []
|
792
|
+
expect(serialized_column.save!.should).to eq(true)
|
793
|
+
end
|
794
|
+
end
|
748
795
|
end
|
@@ -110,6 +110,23 @@ describe "OracleEnhancedConnection" do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
+
describe 'with host="connection-string"' do
|
114
|
+
let(:username) { CONNECTION_PARAMS[:username] }
|
115
|
+
let(:password) { CONNECTION_PARAMS[:password] }
|
116
|
+
let(:connection_string) { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=#{DATABASE_HOST})(PORT=#{DATABASE_PORT})))(CONNECT_DATA=(SERVICE_NAME=#{DATABASE_NAME})))" }
|
117
|
+
let(:params) { { username: username, password: password, host: 'connection-string', database: connection_string } }
|
118
|
+
|
119
|
+
it 'uses the database param as the connection string' do
|
120
|
+
if ORACLE_ENHANCED_CONNECTION == :jdbc
|
121
|
+
expect(java.sql.DriverManager).to receive(:getConnection).with("jdbc:oracle:thin:@#{connection_string}", anything).and_call_original
|
122
|
+
else
|
123
|
+
expect(OCI8).to receive(:new).with(username, password, connection_string, nil).and_call_original
|
124
|
+
end
|
125
|
+
conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
|
126
|
+
expect(conn).to be_active
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
113
130
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
114
131
|
|
115
132
|
describe "create JDBC connection" do
|
@@ -254,11 +254,11 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
254
254
|
column.type_cast_from_database(1.0).class.should == BigDecimal
|
255
255
|
end
|
256
256
|
|
257
|
-
it "should return
|
257
|
+
it "should return Integer value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
|
258
258
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
259
259
|
columns = @conn.columns('test2_employees')
|
260
260
|
column = columns.detect{|c| c.name == "job_id"}
|
261
|
-
column.type_cast_from_database(1.0).
|
261
|
+
expect(column.type_cast_from_database(1.0)).to be_a(Integer)
|
262
262
|
end
|
263
263
|
|
264
264
|
describe "/ NUMBER values from ActiveRecord model" do
|
@@ -291,16 +291,16 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
291
291
|
@employee2.job_id.class.should == BigDecimal
|
292
292
|
end
|
293
293
|
|
294
|
-
it "should return
|
294
|
+
it "should return Integer value from NUMBER column if column name contains 'id' and emulate_integers_by_column_name is true" do
|
295
295
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
296
296
|
create_employee2
|
297
|
-
@employee2.job_id.
|
297
|
+
expect(@employee2.job_id).to be_a(Integer)
|
298
298
|
end
|
299
299
|
|
300
|
-
it "should return
|
300
|
+
it "should return Integer value from NUMBER column with integer value using _before_type_cast method" do
|
301
301
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = true
|
302
302
|
create_employee2
|
303
|
-
@employee2.job_id_before_type_cast.
|
303
|
+
expect(@employee2.job_id_before_type_cast).to be_a(Integer)
|
304
304
|
end
|
305
305
|
|
306
306
|
it "should return BigDecimal value from NUMBER column if column name does not contain 'id' and emulate_integers_by_column_name is true" do
|
@@ -309,11 +309,11 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
309
309
|
@employee2.salary.class.should == BigDecimal
|
310
310
|
end
|
311
311
|
|
312
|
-
it "should return
|
312
|
+
it "should return Integer value from NUMBER column if column specified in set_integer_columns" do
|
313
313
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_integers_by_column_name = false
|
314
314
|
Test2Employee.set_integer_columns :job_id
|
315
315
|
create_employee2
|
316
|
-
@employee2.job_id.
|
316
|
+
expect(@employee2.job_id).to be_a(Integer)
|
317
317
|
end
|
318
318
|
|
319
319
|
it "should return Boolean value from NUMBER(1) column if emulate booleans is used" do
|
@@ -322,17 +322,17 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
322
322
|
@employee2.is_manager.class.should == TrueClass
|
323
323
|
end
|
324
324
|
|
325
|
-
it "should return
|
325
|
+
it "should return Integer value from NUMBER(1) column if emulate booleans is not used" do
|
326
326
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = false
|
327
327
|
create_employee2
|
328
|
-
@employee2.is_manager.
|
328
|
+
expect(@employee2.is_manager).to be_a(Integer)
|
329
329
|
end
|
330
330
|
|
331
|
-
it "should return
|
331
|
+
it "should return Integer value from NUMBER(1) column if column specified in set_integer_columns" do
|
332
332
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
|
333
333
|
Test2Employee.set_integer_columns :is_manager
|
334
334
|
create_employee2
|
335
|
-
@employee2.is_manager.
|
335
|
+
expect(@employee2.is_manager).to be_a(Integer)
|
336
336
|
end
|
337
337
|
|
338
338
|
end
|
@@ -844,6 +844,53 @@ end
|
|
844
844
|
end
|
845
845
|
end
|
846
846
|
|
847
|
+
describe "primary key in table definition" do
|
848
|
+
before do
|
849
|
+
@conn = ActiveRecord::Base.connection
|
850
|
+
|
851
|
+
class ::TestPost < ActiveRecord::Base
|
852
|
+
end
|
853
|
+
end
|
854
|
+
|
855
|
+
it 'should use default tablespace for primary key' do
|
856
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:index] = nil
|
857
|
+
schema_define do
|
858
|
+
create_table :test_posts, :force => true
|
859
|
+
end
|
860
|
+
|
861
|
+
index_name = @conn.select_value(
|
862
|
+
"SELECT index_name FROM all_constraints
|
863
|
+
WHERE table_name = 'TEST_POSTS'
|
864
|
+
AND constraint_type = 'P'
|
865
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')")
|
866
|
+
|
867
|
+
expect(TestPost.connection.select_value("SELECT tablespace_name FROM user_indexes WHERE index_name = '#{index_name}'")).to eq('USERS')
|
868
|
+
end
|
869
|
+
|
870
|
+
it 'should use non default tablespace for primary key' do
|
871
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:index] = DATABASE_NON_DEFAULT_TABLESPACE
|
872
|
+
schema_define do
|
873
|
+
create_table :test_posts, :force => true
|
874
|
+
end
|
875
|
+
|
876
|
+
index_name = @conn.select_value(
|
877
|
+
"SELECT index_name FROM all_constraints
|
878
|
+
WHERE table_name = 'TEST_POSTS'
|
879
|
+
AND constraint_type = 'P'
|
880
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')")
|
881
|
+
|
882
|
+
expect(TestPost.connection.select_value("SELECT tablespace_name FROM user_indexes WHERE index_name = '#{index_name}'")).to eq(DATABASE_NON_DEFAULT_TABLESPACE)
|
883
|
+
end
|
884
|
+
|
885
|
+
after do
|
886
|
+
Object.send(:remove_const, "TestPost")
|
887
|
+
schema_define do
|
888
|
+
drop_table :test_posts rescue nil
|
889
|
+
end
|
890
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:index] = nil
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
847
894
|
describe "foreign key in table definition" do
|
848
895
|
before(:each) do
|
849
896
|
schema_define do
|
@@ -0,0 +1,31 @@
|
|
1
|
+
alter database default tablespace USERS;
|
2
|
+
|
3
|
+
CREATE USER oracle_enhanced IDENTIFIED BY oracle_enhanced;
|
4
|
+
|
5
|
+
GRANT unlimited tablespace, create session, create table, create sequence,
|
6
|
+
create procedure, create trigger, create view, create materialized view,
|
7
|
+
create database link, create synonym, create type, ctxapp TO oracle_enhanced;
|
8
|
+
|
9
|
+
CREATE USER oracle_enhanced_schema IDENTIFIED BY oracle_enhanced_schema;
|
10
|
+
|
11
|
+
GRANT unlimited tablespace, create session, create table, create sequence,
|
12
|
+
create procedure, create trigger, create view, create materialized view,
|
13
|
+
create database link, create synonym, create type, ctxapp TO oracle_enhanced_schema;
|
14
|
+
|
15
|
+
CREATE USER arunit IDENTIFIED BY arunit;
|
16
|
+
|
17
|
+
GRANT unlimited tablespace, create session, create table, create sequence,
|
18
|
+
create procedure, create trigger, create view, create materialized view,
|
19
|
+
create database link, create synonym, create type, ctxapp TO arunit;
|
20
|
+
|
21
|
+
CREATE USER arunit2 IDENTIFIED BY arunit2;
|
22
|
+
|
23
|
+
GRANT unlimited tablespace, create session, create table, create sequence,
|
24
|
+
create procedure, create trigger, create view, create materialized view,
|
25
|
+
create database link, create synonym, create type, ctxapp TO arunit2;
|
26
|
+
|
27
|
+
CREATE USER ruby IDENTIFIED BY oci8;
|
28
|
+
GRANT connect, resource, create view,create synonym TO ruby;
|
29
|
+
GRANT EXECUTE ON dbms_lock TO ruby;
|
30
|
+
GRANT CREATE VIEW TO ruby;
|
31
|
+
GRANT unlimited tablespace to ruby;
|
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.6.
|
4
|
+
version: 1.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,6 +202,10 @@ extra_rdoc_files:
|
|
202
202
|
- README.md
|
203
203
|
files:
|
204
204
|
- ".rspec"
|
205
|
+
- ".travis.yml"
|
206
|
+
- ".travis/oracle/download.sh"
|
207
|
+
- ".travis/oracle/install.sh"
|
208
|
+
- ".travis/setup_accounts.sh"
|
205
209
|
- Gemfile
|
206
210
|
- History.md
|
207
211
|
- License.txt
|
@@ -249,6 +253,8 @@ files:
|
|
249
253
|
- spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb
|
250
254
|
- spec/spec_config.yaml.template
|
251
255
|
- spec/spec_helper.rb
|
256
|
+
- spec/support/alter_system_user_password.sql
|
257
|
+
- spec/support/create_oracle_enhanced_users.sql
|
252
258
|
homepage: http://github.com/rsim/oracle-enhanced
|
253
259
|
licenses:
|
254
260
|
- MIT
|
@@ -269,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
275
|
version: '0'
|
270
276
|
requirements: []
|
271
277
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.
|
278
|
+
rubygems_version: 2.6.10
|
273
279
|
signing_key:
|
274
280
|
specification_version: 4
|
275
281
|
summary: Oracle enhanced adapter for ActiveRecord
|