activerecord-oracle_enhanced-adapter 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/Gemfile +35 -30
- data/History.txt +14 -0
- data/License.txt +1 -1
- data/README.rdoc +4 -1
- data/RUNNING_TESTS.rdoc +1 -1
- data/Rakefile +24 -26
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +95 -68
- data/lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb +7 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +147 -18
- data/lib/active_record/connection_adapters/oracle_enhanced_column.rb +31 -15
- data/lib/active_record/connection_adapters/oracle_enhanced_connection.rb +0 -2
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +146 -51
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +57 -18
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +7 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +6 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +6 -9
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +63 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +232 -151
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +5 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb +1 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +61 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +10 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +49 -4
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +1 -1
- data/spec/spec_helper.rb +7 -17
- metadata +160 -16
- data/.gitignore +0 -11
- data/spec/spec.opts +0 -6
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -1,37 +1,42 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
gem '
|
3
|
+
group :development do
|
4
|
+
gem 'jeweler', '~> 1.5.1'
|
5
|
+
gem 'rspec', '~> 2.4'
|
5
6
|
|
6
|
-
if ENV['RAILS_GEM_VERSION']
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
else
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
7
|
+
if ENV['RAILS_GEM_VERSION']
|
8
|
+
gem 'activerecord', "=#{ENV['RAILS_GEM_VERSION']}"
|
9
|
+
gem 'actionpack', "=#{ENV['RAILS_GEM_VERSION']}"
|
10
|
+
gem 'activesupport', "=#{ENV['RAILS_GEM_VERSION']}"
|
11
|
+
case ENV['RAILS_GEM_VERSION']
|
12
|
+
when /^2.0/
|
13
|
+
gem 'composite_primary_keys', '=0.9.93'
|
14
|
+
when /^2.1/
|
15
|
+
gem 'composite_primary_keys', '=1.0.8'
|
16
|
+
when /^2.2/
|
17
|
+
gem 'composite_primary_keys', '=2.2.2'
|
18
|
+
when /^2.3.3/
|
19
|
+
gem 'composite_primary_keys', '=2.3.2'
|
20
|
+
when /^3/
|
21
|
+
gem 'railties', "=#{ENV['RAILS_GEM_VERSION']}"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
# uses local copy of Rails 3 and Arel gems
|
25
|
+
ENV['RAILS_GEM_PATH'] ||= File.expand_path('../../rails', __FILE__)
|
26
|
+
%w(activerecord activemodel activesupport actionpack railties).each do |gem_name|
|
27
|
+
gem gem_name, :path => File.join(ENV['RAILS_GEM_PATH'], gem_name)
|
28
|
+
end
|
29
|
+
|
30
|
+
ENV['AREL_GEM_PATH'] ||= File.expand_path('../../arel', __FILE__)
|
31
|
+
gem 'arel', :path => ENV['AREL_GEM_PATH']
|
32
|
+
|
33
|
+
gem 'rack', :git => 'git://github.com/rack/rack.git'
|
27
34
|
end
|
28
35
|
|
29
|
-
|
30
|
-
gem 'arel', :path => ENV['AREL_GEM_PATH']
|
31
|
-
end
|
36
|
+
gem 'ruby-plsql', '>=0.4.4'
|
32
37
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
38
|
+
platforms :ruby do
|
39
|
+
gem 'ruby-oci8', '~> 2.0.4'
|
40
|
+
end
|
36
41
|
|
37
|
-
|
42
|
+
end
|
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
== 1.3.2 2011-01-05
|
2
|
+
|
3
|
+
* Enhancements:
|
4
|
+
* If no :host or :port is provided then connect with :database name (do not default :host to localhost)
|
5
|
+
* Database connection pool support for JRuby on Tomcat and JBoss application servers
|
6
|
+
* NLS connection parameters support via environment variables or database.yml
|
7
|
+
* Support for Arel 2.0 and latest Rails master branch
|
8
|
+
* Support for Rails 3.1 prepared statements (implemented in not yet released Rails master branch version)
|
9
|
+
* Eager loading of included association with more than 1000 records (implemented in not yet released Rails master branch version)
|
10
|
+
* Bug fixes:
|
11
|
+
* Foreign keys are added after table definitions in schema dump to ensure correct order of schema statements
|
12
|
+
* Quote NCHAR and NVARCHAR2 type values with N'...'
|
13
|
+
* Numeric username and/or password in database.yml will be automatically converted to string
|
14
|
+
|
1
15
|
== 1.3.1 2010-09-09
|
2
16
|
|
3
17
|
* Enhancements:
|
data/License.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2008-
|
1
|
+
Copyright (c) 2008-2011 Graham Jenkins, Michael Schoen, Raimonds Simanovskis
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.rdoc
CHANGED
@@ -59,12 +59,15 @@ See RUNNING_TESTS.rdoc
|
|
59
59
|
* Simon Chiang
|
60
60
|
* Peter Nyberg
|
61
61
|
* Dwayne Litzenberger
|
62
|
+
* Aaron Patterson
|
63
|
+
* Darcy Schultz
|
64
|
+
* Alexi Rahman
|
62
65
|
|
63
66
|
== LICENSE:
|
64
67
|
|
65
68
|
(The MIT License)
|
66
69
|
|
67
|
-
Copyright (c) 2008-
|
70
|
+
Copyright (c) 2008-2011 Graham Jenkins, Michael Schoen, Raimonds Simanovskis
|
68
71
|
|
69
72
|
Permission is hereby granted, free of charge, to any person obtaining
|
70
73
|
a copy of this software and associated documentation files (the
|
data/RUNNING_TESTS.rdoc
CHANGED
@@ -21,7 +21,7 @@ It is recommended to use RVM (http://rvm.beginrescueend.com) to run tests with d
|
|
21
21
|
* Install bundler with
|
22
22
|
gem install bundler
|
23
23
|
* Set RAILS_GEM_VERSION to Rails version that you would like to use in oracle_enhanced tests, e.g.
|
24
|
-
export RAILS_GEM_VERSION=3.0.
|
24
|
+
export RAILS_GEM_VERSION=3.0.3
|
25
25
|
* Install necessary gems with
|
26
26
|
bundle install
|
27
27
|
* Run tests with
|
data/Rakefile
CHANGED
@@ -1,40 +1,38 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
|
2
11
|
require 'rake'
|
3
12
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
gem.description = <<-EOS
|
13
|
+
require 'jeweler'
|
14
|
+
Jeweler::Tasks.new do |gem|
|
15
|
+
gem.name = "activerecord-oracle_enhanced-adapter"
|
16
|
+
gem.summary = "Oracle enhanced adapter for ActiveRecord"
|
17
|
+
gem.description = <<-EOS
|
10
18
|
Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
11
19
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
12
20
|
EOS
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
gem.extra_rdoc_files = ['README.rdoc']
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
gem.email = "raimonds.simanovskis@gmail.com"
|
22
|
+
gem.homepage = "http://github.com/rsim/oracle-enhanced"
|
23
|
+
gem.authors = ["Raimonds Simanovskis"]
|
24
|
+
gem.extra_rdoc_files = ['README.rdoc']
|
22
25
|
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
23
27
|
|
24
|
-
require '
|
25
|
-
|
26
|
-
spec.libs << 'lib' << 'spec'
|
27
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
-
end
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
RSpec::Core::RakeTask.new(:spec)
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
spec.rcov = true
|
31
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
32
|
+
t.rcov = true
|
33
|
+
t.rcov_opts = ['--exclude', '/Library,spec/']
|
34
34
|
end
|
35
35
|
|
36
|
-
task :spec => :check_dependencies
|
37
|
-
|
38
36
|
task :default => :spec
|
39
37
|
|
40
38
|
require 'rake/rdoctask'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.2
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{activerecord-oracle_enhanced-adapter}
|
8
|
-
s.version = "1.3.
|
8
|
+
s.version = "1.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Raimonds Simanovskis"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-05}
|
13
13
|
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
14
14
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
15
15
|
}
|
@@ -18,86 +18,113 @@ This adapter is superset of original ActiveRecord Oracle adapter.
|
|
18
18
|
"README.rdoc"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
-
".
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
"spec/spec_helper.rb"
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"History.txt",
|
24
|
+
"License.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"RUNNING_TESTS.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"activerecord-oracle_enhanced-adapter.gemspec",
|
30
|
+
"lib/active_record/connection_adapters/emulation/oracle_adapter.rb",
|
31
|
+
"lib/active_record/connection_adapters/oracle_enhanced.rake",
|
32
|
+
"lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb",
|
33
|
+
"lib/active_record/connection_adapters/oracle_enhanced_adapter.rb",
|
34
|
+
"lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb",
|
35
|
+
"lib/active_record/connection_adapters/oracle_enhanced_column.rb",
|
36
|
+
"lib/active_record/connection_adapters/oracle_enhanced_connection.rb",
|
37
|
+
"lib/active_record/connection_adapters/oracle_enhanced_context_index.rb",
|
38
|
+
"lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb",
|
39
|
+
"lib/active_record/connection_adapters/oracle_enhanced_cpk.rb",
|
40
|
+
"lib/active_record/connection_adapters/oracle_enhanced_dirty.rb",
|
41
|
+
"lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb",
|
42
|
+
"lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb",
|
43
|
+
"lib/active_record/connection_adapters/oracle_enhanced_procedures.rb",
|
44
|
+
"lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb",
|
45
|
+
"lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb",
|
46
|
+
"lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb",
|
47
|
+
"lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb",
|
48
|
+
"lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb",
|
49
|
+
"lib/active_record/connection_adapters/oracle_enhanced_tasks.rb",
|
50
|
+
"lib/active_record/connection_adapters/oracle_enhanced_version.rb",
|
51
|
+
"lib/activerecord-oracle_enhanced-adapter.rb",
|
52
|
+
"spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb",
|
53
|
+
"spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb",
|
54
|
+
"spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb",
|
55
|
+
"spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb",
|
56
|
+
"spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb",
|
57
|
+
"spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb",
|
58
|
+
"spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb",
|
59
|
+
"spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb",
|
60
|
+
"spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb",
|
61
|
+
"spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb",
|
62
|
+
"spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb",
|
63
|
+
"spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb",
|
64
|
+
"spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb",
|
65
|
+
"spec/spec_helper.rb"
|
67
66
|
]
|
68
67
|
s.homepage = %q{http://github.com/rsim/oracle-enhanced}
|
69
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
70
68
|
s.require_paths = ["lib"]
|
71
|
-
s.rubygems_version = %q{1.
|
69
|
+
s.rubygems_version = %q{1.4.1}
|
72
70
|
s.summary = %q{Oracle enhanced adapter for ActiveRecord}
|
73
71
|
s.test_files = [
|
74
72
|
"spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb",
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
73
|
+
"spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb",
|
74
|
+
"spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb",
|
75
|
+
"spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb",
|
76
|
+
"spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb",
|
77
|
+
"spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb",
|
78
|
+
"spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb",
|
79
|
+
"spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb",
|
80
|
+
"spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb",
|
81
|
+
"spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb",
|
82
|
+
"spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb",
|
83
|
+
"spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb",
|
84
|
+
"spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb",
|
85
|
+
"spec/spec_helper.rb"
|
88
86
|
]
|
89
87
|
|
90
88
|
if s.respond_to? :specification_version then
|
91
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
92
89
|
s.specification_version = 3
|
93
90
|
|
94
91
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
95
|
-
s.add_development_dependency(%q<
|
92
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
|
93
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.4"])
|
94
|
+
s.add_development_dependency(%q<activerecord>, [">= 0"])
|
95
|
+
s.add_development_dependency(%q<activemodel>, [">= 0"])
|
96
|
+
s.add_development_dependency(%q<activesupport>, [">= 0"])
|
97
|
+
s.add_development_dependency(%q<actionpack>, [">= 0"])
|
98
|
+
s.add_development_dependency(%q<railties>, [">= 0"])
|
99
|
+
s.add_development_dependency(%q<arel>, [">= 0"])
|
100
|
+
s.add_development_dependency(%q<rack>, [">= 0"])
|
101
|
+
s.add_development_dependency(%q<ruby-plsql>, [">= 0.4.4"])
|
102
|
+
s.add_development_dependency(%q<ruby-oci8>, ["~> 2.0.4"])
|
96
103
|
else
|
97
|
-
s.add_dependency(%q<
|
104
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
105
|
+
s.add_dependency(%q<rspec>, ["~> 2.4"])
|
106
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
107
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
108
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
109
|
+
s.add_dependency(%q<actionpack>, [">= 0"])
|
110
|
+
s.add_dependency(%q<railties>, [">= 0"])
|
111
|
+
s.add_dependency(%q<arel>, [">= 0"])
|
112
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
113
|
+
s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
|
114
|
+
s.add_dependency(%q<ruby-oci8>, ["~> 2.0.4"])
|
98
115
|
end
|
99
116
|
else
|
100
|
-
s.add_dependency(%q<
|
117
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
|
118
|
+
s.add_dependency(%q<rspec>, ["~> 2.4"])
|
119
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
120
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
121
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
122
|
+
s.add_dependency(%q<actionpack>, [">= 0"])
|
123
|
+
s.add_dependency(%q<railties>, [">= 0"])
|
124
|
+
s.add_dependency(%q<arel>, [">= 0"])
|
125
|
+
s.add_dependency(%q<rack>, [">= 0"])
|
126
|
+
s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
|
127
|
+
s.add_dependency(%q<ruby-oci8>, ["~> 2.0.4"])
|
101
128
|
end
|
102
129
|
end
|
103
130
|
|
@@ -6,9 +6,13 @@ if ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 3
|
|
6
6
|
private
|
7
7
|
def tables_in_string(string)
|
8
8
|
return [] if string.blank?
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
if self.connection.adapter_name == "OracleEnhanced"
|
10
|
+
# always convert table names to downcase as in Oracle quoted table names are in uppercase
|
11
|
+
# ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries
|
12
|
+
string.scan(/([a-zA-Z_][\.\w]+).?\./).flatten.map(&:downcase).uniq - ['raw_sql_']
|
13
|
+
else
|
14
|
+
string.scan(/([\.a-zA-Z_]+).?\./).flatten
|
15
|
+
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -80,10 +80,32 @@ module ActiveRecord
|
|
80
80
|
# * <tt>:allow_concurrency</tt> - set to "true" if non-blocking mode should be enabled (just for OCI client)
|
81
81
|
# * <tt>:prefetch_rows</tt> - how many rows should be fetched at one time to increase performance, defaults to 100
|
82
82
|
# * <tt>:cursor_sharing</tt> - cursor sharing mode to minimize amount of unique statements, defaults to "force"
|
83
|
-
# * <tt>:nls_length_semantics</tt> - semantics of size of VARCHAR2 and CHAR columns, defaults to "CHAR"
|
84
|
-
# (meaning that size specifies number of characters and not bytes)
|
85
83
|
# * <tt>:time_zone</tt> - database session time zone
|
86
84
|
# (it is recommended to set it using ENV['TZ'] which will be then also used for database session time zone)
|
85
|
+
#
|
86
|
+
# Optionals NLS parameters:
|
87
|
+
#
|
88
|
+
# * <tt>:nls_calendar</tt>
|
89
|
+
# * <tt>:nls_characterset</tt>
|
90
|
+
# * <tt>:nls_comp</tt>
|
91
|
+
# * <tt>:nls_currency</tt>
|
92
|
+
# * <tt>:nls_date_format</tt> - format for :date columns, defaults to <tt>YYYY-MM-DD HH24:MI:SS</tt>
|
93
|
+
# * <tt>:nls_date_language</tt>
|
94
|
+
# * <tt>:nls_dual_currency</tt>
|
95
|
+
# * <tt>:nls_iso_currency</tt>
|
96
|
+
# * <tt>:nls_language</tt>
|
97
|
+
# * <tt>:nls_length_semantics</tt> - semantics of size of VARCHAR2 and CHAR columns, defaults to <tt>CHAR</tt>
|
98
|
+
# (meaning that size specifies number of characters and not bytes)
|
99
|
+
# * <tt>:nls_nchar_characterset</tt>
|
100
|
+
# * <tt>:nls_nchar_conv_excp</tt>
|
101
|
+
# * <tt>:nls_numeric_characters</tt>
|
102
|
+
# * <tt>:nls_sort</tt>
|
103
|
+
# * <tt>:nls_territory</tt>
|
104
|
+
# * <tt>:nls_timestamp_format</tt> - format for :timestamp columns, defaults to <tt>YYYY-MM-DD HH24:MI:SS:FF6</tt>
|
105
|
+
# * <tt>:nls_timestamp_tz_format</tt>
|
106
|
+
# * <tt>:nls_time_format</tt>
|
107
|
+
# * <tt>:nls_time_tz_format</tt>
|
108
|
+
#
|
87
109
|
class OracleEnhancedAdapter < AbstractAdapter
|
88
110
|
|
89
111
|
##
|
@@ -203,6 +225,7 @@ module ActiveRecord
|
|
203
225
|
def initialize(connection, logger = nil) #:nodoc:
|
204
226
|
super
|
205
227
|
@quoted_column_names, @quoted_table_names = {}, {}
|
228
|
+
@statements = {}
|
206
229
|
@enable_dbms_output = false
|
207
230
|
end
|
208
231
|
|
@@ -224,6 +247,29 @@ module ActiveRecord
|
|
224
247
|
true
|
225
248
|
end
|
226
249
|
|
250
|
+
#:stopdoc:
|
251
|
+
DEFAULT_NLS_PARAMETERS = {
|
252
|
+
:nls_calendar => nil,
|
253
|
+
:nls_characterset => nil,
|
254
|
+
:nls_comp => nil,
|
255
|
+
:nls_currency => nil,
|
256
|
+
:nls_date_format => 'YYYY-MM-DD HH24:MI:SS',
|
257
|
+
:nls_date_language => nil,
|
258
|
+
:nls_dual_currency => nil,
|
259
|
+
:nls_iso_currency => nil,
|
260
|
+
:nls_language => nil,
|
261
|
+
:nls_length_semantics => 'CHAR',
|
262
|
+
:nls_nchar_characterset => nil,
|
263
|
+
:nls_nchar_conv_excp => nil,
|
264
|
+
:nls_numeric_characters => nil,
|
265
|
+
:nls_sort => nil,
|
266
|
+
:nls_territory => nil,
|
267
|
+
:nls_timestamp_format => 'YYYY-MM-DD HH24:MI:SS:FF6',
|
268
|
+
:nls_timestamp_tz_format => nil,
|
269
|
+
:nls_time_format => nil,
|
270
|
+
:nls_time_tz_format => nil
|
271
|
+
}
|
272
|
+
|
227
273
|
#:stopdoc:
|
228
274
|
NATIVE_DATABASE_TYPES = {
|
229
275
|
:primary_key => "NUMBER(38) NOT NULL PRIMARY KEY",
|
@@ -273,6 +319,12 @@ module ActiveRecord
|
|
273
319
|
IDENTIFIER_MAX_LENGTH
|
274
320
|
end
|
275
321
|
|
322
|
+
# To avoid ORA-01795: maximum number of expressions in a list is 1000
|
323
|
+
# tell ActiveRecord to limit us to 1000 ids at a time
|
324
|
+
def in_clause_length
|
325
|
+
1000
|
326
|
+
end
|
327
|
+
|
276
328
|
# QUOTING ==================================================
|
277
329
|
#
|
278
330
|
# see: abstract/quoting.rb
|
@@ -343,6 +395,12 @@ module ActiveRecord
|
|
343
395
|
# NLS_DATE_FORMAT independent DATE support
|
344
396
|
when :date, :time, :datetime
|
345
397
|
quote_date_with_to_date(value)
|
398
|
+
when :string
|
399
|
+
# NCHAR and NVARCHAR2 literals should be quoted with N'...'.
|
400
|
+
# Read directly instance variable as otherwise migrations with table column default values are failing
|
401
|
+
# as migrations pass ColumnDefinition object to this method.
|
402
|
+
# Check if instance variable is defined to avoid warnings about accessing undefined instance variable.
|
403
|
+
column.instance_variable_defined?('@nchar') && column.instance_variable_get('@nchar') ? 'N' << super : super
|
346
404
|
else
|
347
405
|
super
|
348
406
|
end
|
@@ -409,13 +467,20 @@ module ActiveRecord
|
|
409
467
|
|
410
468
|
# Reconnects to the database.
|
411
469
|
def reconnect! #:nodoc:
|
470
|
+
clear_cache!
|
412
471
|
@connection.reset!
|
413
472
|
rescue OracleEnhancedConnectionException => e
|
414
473
|
@logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" if @logger
|
415
474
|
end
|
416
475
|
|
476
|
+
def reset!
|
477
|
+
clear_cache!
|
478
|
+
super
|
479
|
+
end
|
480
|
+
|
417
481
|
# Disconnects from the database.
|
418
482
|
def disconnect! #:nodoc:
|
483
|
+
clear_cache!
|
419
484
|
@connection.logoff rescue nil
|
420
485
|
end
|
421
486
|
|
@@ -425,16 +490,67 @@ module ActiveRecord
|
|
425
490
|
|
426
491
|
# Executes a SQL statement
|
427
492
|
def execute(sql, name = nil)
|
428
|
-
|
429
|
-
|
430
|
-
|
493
|
+
log(sql, name) { @connection.exec(sql) }
|
494
|
+
end
|
495
|
+
|
496
|
+
def substitute_for(column, current_values)
|
497
|
+
Arel.sql(":a#{current_values.length + 1}")
|
498
|
+
end
|
499
|
+
|
500
|
+
def clear_cache!
|
501
|
+
@statements.each_value do |cursor|
|
502
|
+
cursor.close
|
503
|
+
end
|
504
|
+
@statements.clear
|
505
|
+
end
|
506
|
+
|
507
|
+
def exec_query(sql, name = 'SQL', binds = [])
|
508
|
+
log(sql, name) do
|
509
|
+
cursor = nil
|
510
|
+
cached = false
|
511
|
+
if binds.empty?
|
512
|
+
cursor = @connection.prepare(sql)
|
513
|
+
else
|
514
|
+
unless @statements.key? sql
|
515
|
+
@statements[sql] = @connection.prepare(sql)
|
516
|
+
end
|
517
|
+
|
518
|
+
cursor = @statements[sql]
|
519
|
+
|
520
|
+
binds = binds.map do |col, val|
|
521
|
+
col ? col.type_cast(val) : val
|
522
|
+
end
|
523
|
+
binds.each_with_index { |val, i| cursor.bind_param(i + 1, val) }
|
524
|
+
cached = true
|
525
|
+
end
|
526
|
+
|
527
|
+
cursor.exec
|
528
|
+
columns = cursor.get_col_names.map do |col_name|
|
529
|
+
@connection.oracle_downcase(col_name)
|
530
|
+
end
|
531
|
+
rows = []
|
532
|
+
fetch_options = {:get_lob_value => (name != 'Writable Large Object')}
|
533
|
+
while row = cursor.fetch(fetch_options)
|
534
|
+
rows << row
|
535
|
+
end
|
536
|
+
res = ActiveRecord::Result.new(columns, rows)
|
537
|
+
cursor.close unless cached
|
538
|
+
res
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
def supports_statement_cache?
|
543
|
+
true
|
431
544
|
end
|
432
545
|
|
433
546
|
# Returns an array of arrays containing the field values.
|
434
547
|
# Order is the same as that returned by #columns.
|
435
548
|
def select_rows(sql, name = nil)
|
436
549
|
# last parameter indicates to return also column list
|
437
|
-
result
|
550
|
+
result = columns = nil
|
551
|
+
log(sql, name) do
|
552
|
+
result, columns = @connection.select(sql, name, true)
|
553
|
+
end
|
438
554
|
result.map{ |v| columns.map{|c| v[c]} }
|
439
555
|
end
|
440
556
|
|
@@ -447,10 +563,10 @@ module ActiveRecord
|
|
447
563
|
return id_value
|
448
564
|
end
|
449
565
|
|
450
|
-
sql_with_returning = sql
|
451
|
-
|
452
|
-
|
453
|
-
|
566
|
+
sql_with_returning = sql + @connection.returning_clause(quote_column_name(pk))
|
567
|
+
log(sql, name) do
|
568
|
+
@connection.exec_with_returning(sql_with_returning)
|
569
|
+
end
|
454
570
|
end
|
455
571
|
protected :insert_sql
|
456
572
|
|
@@ -463,7 +579,8 @@ module ActiveRecord
|
|
463
579
|
def next_sequence_value(sequence_name)
|
464
580
|
# if sequence_name is set to :autogenerated then it means that primary key will be populated by trigger
|
465
581
|
return nil if sequence_name == AUTOGENERATED_SEQUENCE_NAME
|
466
|
-
|
582
|
+
# call directly connection method to avoid prepared statement which causes fetching of next sequence value twice
|
583
|
+
@connection.select_value("SELECT #{quote_table_name(sequence_name)}.NEXTVAL FROM dual")
|
467
584
|
end
|
468
585
|
|
469
586
|
def begin_db_transaction #:nodoc:
|
@@ -862,9 +979,15 @@ module ActiveRecord
|
|
862
979
|
|
863
980
|
# construct a valid DISTINCT clause, ie. one that includes the ORDER BY columns, using
|
864
981
|
# FIRST_VALUE such that the inclusion of these columns doesn't invalidate the DISTINCT
|
865
|
-
order_columns = order_by.
|
982
|
+
order_columns = if order_by.is_a?(String)
|
983
|
+
order_by.split(',').map { |s| s.strip }.reject(&:blank?)
|
984
|
+
else # in latest ActiveRecord versions order_by is already Array
|
985
|
+
order_by
|
986
|
+
end
|
866
987
|
order_columns = order_columns.zip((0...order_columns.size).to_a).map do |c, i|
|
867
|
-
|
988
|
+
# remove any ASC/DESC modifiers
|
989
|
+
value = c =~ /^(.+)\s+(ASC|DESC)\s*$/i ? $1 : c
|
990
|
+
"FIRST_VALUE(#{value}) OVER (PARTITION BY #{columns} ORDER BY #{c}) AS alias_#{i}__"
|
868
991
|
end
|
869
992
|
sql = "DISTINCT #{columns}, "
|
870
993
|
sql << order_columns * ", "
|
@@ -873,10 +996,12 @@ module ActiveRecord
|
|
873
996
|
def temporary_table?(table_name) #:nodoc:
|
874
997
|
select_value("select temporary from user_tables where table_name = '#{table_name.upcase}'") == 'Y'
|
875
998
|
end
|
876
|
-
|
999
|
+
|
877
1000
|
# ORDER BY clause for the passed order option.
|
878
|
-
#
|
1001
|
+
#
|
879
1002
|
# Uses column aliases as defined by #distinct.
|
1003
|
+
#
|
1004
|
+
# In Rails 3.x this method is moved to Arel
|
880
1005
|
def add_order_by_for_association_limiting!(sql, options) #:nodoc:
|
881
1006
|
return sql if options[:order].blank?
|
882
1007
|
|
@@ -902,9 +1027,13 @@ module ActiveRecord
|
|
902
1027
|
|
903
1028
|
private
|
904
1029
|
|
905
|
-
def select(sql, name = nil,
|
906
|
-
|
907
|
-
|
1030
|
+
def select(sql, name = nil, binds = [])
|
1031
|
+
if ActiveRecord.const_defined?(:Result)
|
1032
|
+
exec_query(sql, name, binds).to_a
|
1033
|
+
else
|
1034
|
+
log(sql, name) do
|
1035
|
+
@connection.select(sql, name, false)
|
1036
|
+
end
|
908
1037
|
end
|
909
1038
|
end
|
910
1039
|
|