activerecord-oracle_enhanced-adapter 1.6.1 → 1.6.2
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 +9 -0
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +4 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +17 -19
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +3 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +46 -0
- 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: ddb7e8953228e3465f579ffe88d131c567000db2
|
4
|
+
data.tar.gz: 031021ed605f3226d77d04f76157c2473ff35e9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 694ae9892d14ccaea9ba755a41137eeceb193510fec5100333e0bf60ec7871fcd63ee8caac7ea073643fcdf473f25b6ba7e3768b4bf67b732dafd8ea067160d2
|
7
|
+
data.tar.gz: eb6efb4b84ad103278ea97bffbfa9e65d58994d5047aa23bf1a4085ff324193d66191b8cee100da00b38bed8068417a09f7ca85c9640bdf4bcf8d1ea1337cbcd
|
data/History.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.6.2 / 2015-07-20
|
2
|
+
|
3
|
+
* Changes and bug fixes since 1.6.1
|
4
|
+
|
5
|
+
* Oracle enhanced adapter v1.6 requires ActiveRecord 4.2.1 or higher,
|
6
|
+
ActiveRecord 4.2.0 is not supported.[#672]
|
7
|
+
* Unique constraints not created when function unique index created [#662, #663]
|
8
|
+
* create_table should use default tablespace values for lobs [#668]
|
9
|
+
|
1
10
|
## 1.6.1 / 2015-07-01
|
2
11
|
|
3
12
|
* Changes and bug fixes since 1.6.0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.2
|
@@ -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.2"
|
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{2015-07-
|
13
|
+
s.date = %q{2015-07-20}
|
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
|
}
|
@@ -119,8 +119,8 @@ This adapter is superset of original ActiveRecord Oracle adapter.
|
|
119
119
|
else
|
120
120
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
121
121
|
s.add_dependency(%q<rspec>, ["~> 2.4"])
|
122
|
-
s.add_dependency(%q<activerecord>, ["
|
123
|
-
s.add_dependency(%q<activemodel>, ["
|
122
|
+
s.add_dependency(%q<activerecord>, ["~> 4.2.1"])
|
123
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
124
124
|
s.add_dependency(%q<activesupport>, [">= 0"])
|
125
125
|
s.add_dependency(%q<actionpack>, [">= 0"])
|
126
126
|
s.add_dependency(%q<railties>, [">= 0"])
|
@@ -5,40 +5,38 @@ module ActiveRecord
|
|
5
5
|
private
|
6
6
|
|
7
7
|
def visit_ColumnDefinition(o)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
case
|
9
|
+
when o.type.to_sym == :virtual
|
10
|
+
sql_type = type_to_sql(o.default[:type], o.limit, o.precision, o.scale) if o.default[:type]
|
11
|
+
return "#{quote_column_name(o.name)} #{sql_type} AS (#{o.default[:as]})"
|
12
|
+
when [:blob, :clob].include?(sql_type = type_to_sql(o.type.to_sym, o.limit, o.precision, o.scale).downcase.to_sym)
|
13
|
+
if (tablespace = default_tablespace_for(sql_type))
|
14
|
+
@lob_tablespaces ||= {}
|
15
|
+
@lob_tablespaces[o.name] = tablespace
|
16
|
+
end
|
13
17
|
end
|
18
|
+
super
|
14
19
|
end
|
15
20
|
|
16
21
|
def visit_TableDefinition(o)
|
17
|
-
tablespace = tablespace_for(:table, o.options[:tablespace])
|
18
22
|
create_sql = "CREATE#{' GLOBAL TEMPORARY' if o.temporary} TABLE "
|
19
23
|
create_sql << "#{quote_table_name(o.name)} ("
|
20
24
|
create_sql << o.columns.map { |c| accept c }.join(', ')
|
21
25
|
create_sql << ")"
|
26
|
+
|
22
27
|
unless o.temporary
|
28
|
+
@lob_tablespaces.each do |lob_column, tablespace|
|
29
|
+
create_sql << " LOB (#{quote_column_name(lob_column)}) STORE AS (TABLESPACE #{tablespace}) \n"
|
30
|
+
end if defined?(@lob_tablespaces)
|
23
31
|
create_sql << " ORGANIZATION #{o.options[:organization]}" if o.options[:organization]
|
24
|
-
|
32
|
+
if (tablespace = o.options[:tablespace] || default_tablespace_for(:table))
|
33
|
+
create_sql << " TABLESPACE #{tablespace}"
|
34
|
+
end
|
25
35
|
end
|
26
36
|
create_sql << " #{o.options[:options]}"
|
27
37
|
create_sql
|
28
38
|
end
|
29
39
|
|
30
|
-
def tablespace_for(obj_type, tablespace_option, table_name=nil, column_name=nil)
|
31
|
-
tablespace_sql = ''
|
32
|
-
if tablespace = (tablespace_option || default_tablespace_for(obj_type))
|
33
|
-
tablespace_sql << if [:blob, :clob].include?(obj_type.to_sym)
|
34
|
-
" LOB (#{quote_column_name(column_name)}) STORE AS #{column_name.to_s[0..10]}_#{table_name.to_s[0..14]}_ls (TABLESPACE #{tablespace})"
|
35
|
-
else
|
36
|
-
" TABLESPACE #{tablespace}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
tablespace_sql
|
40
|
-
end
|
41
|
-
|
42
40
|
def default_tablespace_for(type)
|
43
41
|
(ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[type] ||
|
44
42
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[native_database_types[type][:name]]) rescue nil
|
@@ -166,7 +166,9 @@ module ActiveRecord
|
|
166
166
|
index_name, index_type, quoted_column_names, tablespace, index_options = add_index_options(table_name, column_name, options)
|
167
167
|
execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names})#{tablespace} #{index_options}"
|
168
168
|
if index_type == 'UNIQUE'
|
169
|
-
|
169
|
+
unless quoted_column_names =~ /\(.*\)/
|
170
|
+
execute "ALTER TABLE #{quote_table_name(table_name)} ADD CONSTRAINT #{quote_column_name(index_name)} #{index_type} (#{quoted_column_names})"
|
171
|
+
end
|
170
172
|
end
|
171
173
|
ensure
|
172
174
|
self.all_schema_indexes = nil
|
@@ -804,6 +804,45 @@ end
|
|
804
804
|
|
805
805
|
end
|
806
806
|
|
807
|
+
describe "lob in table definition" do
|
808
|
+
before do
|
809
|
+
class ::TestPost < ActiveRecord::Base
|
810
|
+
end
|
811
|
+
end
|
812
|
+
it 'should use default tablespace for clobs' do
|
813
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = DATABASE_NON_DEFAULT_TABLESPACE
|
814
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:blob] = nil
|
815
|
+
schema_define do
|
816
|
+
create_table :test_posts, :force => true do |t|
|
817
|
+
t.text :test_clob
|
818
|
+
t.binary :test_blob
|
819
|
+
end
|
820
|
+
end
|
821
|
+
TestPost.connection.select_value("SELECT tablespace_name FROM user_lobs WHERE table_name='TEST_POSTS' and column_name = 'TEST_CLOB'").should == DATABASE_NON_DEFAULT_TABLESPACE
|
822
|
+
TestPost.connection.select_value("SELECT tablespace_name FROM user_lobs WHERE table_name='TEST_POSTS' and column_name = 'TEST_BLOB'").should_not == DATABASE_NON_DEFAULT_TABLESPACE
|
823
|
+
end
|
824
|
+
|
825
|
+
it 'should use default tablespace for blobs' do
|
826
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:blob] = DATABASE_NON_DEFAULT_TABLESPACE
|
827
|
+
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[:clob] = nil
|
828
|
+
schema_define do
|
829
|
+
create_table :test_posts, :force => true do |t|
|
830
|
+
t.text :test_clob
|
831
|
+
t.binary :test_blob
|
832
|
+
end
|
833
|
+
end
|
834
|
+
TestPost.connection.select_value("SELECT tablespace_name FROM user_lobs WHERE table_name='TEST_POSTS' and column_name = 'TEST_BLOB'").should == DATABASE_NON_DEFAULT_TABLESPACE
|
835
|
+
TestPost.connection.select_value("SELECT tablespace_name FROM user_lobs WHERE table_name='TEST_POSTS' and column_name = 'TEST_CLOB'").should_not == DATABASE_NON_DEFAULT_TABLESPACE
|
836
|
+
end
|
837
|
+
|
838
|
+
after do
|
839
|
+
Object.send(:remove_const, "TestPost")
|
840
|
+
schema_define do
|
841
|
+
drop_table :test_posts rescue nil
|
842
|
+
end
|
843
|
+
end
|
844
|
+
end
|
845
|
+
|
807
846
|
describe "foreign key in table definition" do
|
808
847
|
before(:each) do
|
809
848
|
schema_define do
|
@@ -1368,6 +1407,13 @@ end
|
|
1368
1407
|
@would_execute_sql.should =~ /CREATE +INDEX .* ON .* \(.*\) TABLESPACE #{DATABASE_NON_DEFAULT_TABLESPACE}/
|
1369
1408
|
end
|
1370
1409
|
|
1410
|
+
it "should create unique function index but not create unique constraints" do
|
1411
|
+
schema_define do
|
1412
|
+
add_index :keyboards, 'lower(name)', unique: true, name: :index_keyboards_on_lower_name
|
1413
|
+
end
|
1414
|
+
@would_execute_sql.should_not =~ /ALTER +TABLE .* ADD CONSTRAINT .* UNIQUE \(.*\(.*\)\)/
|
1415
|
+
end
|
1416
|
+
|
1371
1417
|
describe "#initialize_schema_migrations_table" do
|
1372
1418
|
# In Rails 2.3 to 3.2.x the index name for the migrations
|
1373
1419
|
# table is hard-coded. We can modify the index name here
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|