activerecord-oracle_enhanced-adapter 1.4.3 → 5.2.0
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 +5 -5
- data/History.md +1162 -2
- data/README.md +567 -155
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +3 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +19 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +132 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +345 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +52 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +280 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +64 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +59 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +538 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +38 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +46 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +435 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +44 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +196 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +164 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +95 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +79 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +194 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +709 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +28 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +353 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +33 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +3 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +385 -1083
- data/lib/active_record/type/oracle_enhanced/boolean.rb +20 -0
- data/lib/active_record/type/oracle_enhanced/integer.rb +15 -0
- data/lib/active_record/type/oracle_enhanced/json.rb +10 -0
- data/lib/active_record/type/oracle_enhanced/national_character_string.rb +26 -0
- data/lib/active_record/type/oracle_enhanced/national_character_text.rb +36 -0
- data/lib/active_record/type/oracle_enhanced/raw.rb +25 -0
- data/lib/active_record/type/oracle_enhanced/string.rb +29 -0
- data/lib/active_record/type/oracle_enhanced/text.rb +32 -0
- data/lib/active_record/type/oracle_enhanced/timestampltz.rb +25 -0
- data/lib/active_record/type/oracle_enhanced/timestamptz.rb +25 -0
- data/lib/activerecord-oracle_enhanced-adapter.rb +5 -13
- data/spec/active_record/connection_adapters/{oracle_enhanced_emulate_oracle_adapter_spec.rb → emulation/oracle_adapter_spec.rb} +5 -4
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +469 -0
- data/spec/active_record/connection_adapters/{oracle_enhanced_context_index_spec.rb → oracle_enhanced/context_index_spec.rb} +140 -128
- data/spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb +112 -0
- data/spec/active_record/connection_adapters/{oracle_enhanced_dbms_output_spec.rb → oracle_enhanced/dbms_output_spec.rb} +13 -13
- data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +365 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb +196 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +492 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +1433 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +478 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +385 -550
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +92 -1249
- data/spec/active_record/oracle_enhanced/type/binary_spec.rb +119 -0
- data/spec/active_record/oracle_enhanced/type/boolean_spec.rb +208 -0
- data/spec/active_record/oracle_enhanced/type/dirty_spec.rb +139 -0
- data/spec/active_record/oracle_enhanced/type/float_spec.rb +48 -0
- data/spec/active_record/oracle_enhanced/type/integer_spec.rb +91 -0
- data/spec/active_record/oracle_enhanced/type/json_spec.rb +57 -0
- data/spec/active_record/oracle_enhanced/type/national_character_string_spec.rb +55 -0
- data/spec/active_record/oracle_enhanced/type/national_character_text_spec.rb +230 -0
- data/spec/active_record/oracle_enhanced/type/raw_spec.rb +122 -0
- data/spec/active_record/oracle_enhanced/type/text_spec.rb +229 -0
- data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +75 -0
- data/spec/spec_config.yaml.template +11 -0
- data/spec/spec_helper.rb +100 -93
- data/spec/support/alter_system_set_open_cursors.sql +1 -0
- data/spec/support/alter_system_user_password.sql +2 -0
- data/spec/support/create_oracle_enhanced_users.sql +31 -0
- metadata +105 -152
- data/.rspec +0 -2
- data/Gemfile +0 -52
- data/RUNNING_TESTS.md +0 -45
- data/Rakefile +0 -59
- data/activerecord-oracle_enhanced-adapter.gemspec +0 -130
- data/lib/active_record/connection_adapters/oracle_enhanced.rake +0 -105
- data/lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb +0 -41
- data/lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb +0 -121
- data/lib/active_record/connection_adapters/oracle_enhanced_column.rb +0 -151
- data/lib/active_record/connection_adapters/oracle_enhanced_connection.rb +0 -119
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +0 -359
- data/lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb +0 -25
- data/lib/active_record/connection_adapters/oracle_enhanced_cpk.rb +0 -21
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +0 -46
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +0 -572
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +0 -497
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +0 -260
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +0 -227
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +0 -260
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +0 -428
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +0 -258
- data/lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb +0 -294
- data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +0 -17
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +0 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +0 -334
- data/spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb +0 -19
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +0 -141
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +0 -378
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +0 -440
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +0 -1400
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +0 -339
data/Rakefile
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
|
|
11
|
-
require 'rake'
|
|
12
|
-
|
|
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
|
|
18
|
-
Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
|
19
|
-
This adapter is superset of original ActiveRecord Oracle adapter.
|
|
20
|
-
EOS
|
|
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.md']
|
|
25
|
-
end
|
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
|
27
|
-
|
|
28
|
-
require 'rspec/core/rake_task'
|
|
29
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
30
|
-
|
|
31
|
-
RSpec::Core::RakeTask.new(:rcov) do |t|
|
|
32
|
-
t.rcov = true
|
|
33
|
-
t.rcov_opts = ['--exclude', '/Library,spec/']
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
desc "Clear test database"
|
|
37
|
-
task :clear do
|
|
38
|
-
require "./spec/spec_helper"
|
|
39
|
-
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
|
40
|
-
require "active_support/core_ext"
|
|
41
|
-
ActiveRecord::Base.connection.execute_structure_dump(ActiveRecord::Base.connection.full_drop)
|
|
42
|
-
ActiveRecord::Base.connection.execute("PURGE RECYCLEBIN") rescue nil
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Clear test database before running spec and rcov
|
|
46
|
-
task :spec => :clear
|
|
47
|
-
task :rcov => :clear
|
|
48
|
-
|
|
49
|
-
task :default => :spec
|
|
50
|
-
|
|
51
|
-
require 'rdoc/task'
|
|
52
|
-
Rake::RDocTask.new do |rdoc|
|
|
53
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
|
54
|
-
|
|
55
|
-
rdoc.rdoc_dir = 'doc'
|
|
56
|
-
rdoc.title = "activerecord-oracle_enhanced-adapter #{version}"
|
|
57
|
-
rdoc.rdoc_files.include('README*')
|
|
58
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
59
|
-
end
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |s|
|
|
7
|
-
s.name = %q{activerecord-oracle_enhanced-adapter}
|
|
8
|
-
s.version = "1.4.3"
|
|
9
|
-
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
-
s.authors = [%q{Raimonds Simanovskis}]
|
|
12
|
-
s.date = %q{2013-10-24}
|
|
13
|
-
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
|
14
|
-
This adapter is superset of original ActiveRecord Oracle adapter.
|
|
15
|
-
}
|
|
16
|
-
s.email = %q{raimonds.simanovskis@gmail.com}
|
|
17
|
-
s.extra_rdoc_files = [
|
|
18
|
-
"README.md"
|
|
19
|
-
]
|
|
20
|
-
s.files = [
|
|
21
|
-
".rspec",
|
|
22
|
-
"Gemfile",
|
|
23
|
-
"History.md",
|
|
24
|
-
"License.txt",
|
|
25
|
-
"README.md",
|
|
26
|
-
"RUNNING_TESTS.md",
|
|
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"
|
|
66
|
-
]
|
|
67
|
-
s.homepage = %q{http://github.com/rsim/oracle-enhanced}
|
|
68
|
-
s.require_paths = [%q{lib}]
|
|
69
|
-
s.rubygems_version = %q{1.8.6}
|
|
70
|
-
s.summary = %q{Oracle enhanced adapter for ActiveRecord}
|
|
71
|
-
s.test_files = [
|
|
72
|
-
"spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb",
|
|
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"
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
if s.respond_to? :specification_version then
|
|
89
|
-
s.specification_version = 3
|
|
90
|
-
|
|
91
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
92
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
|
|
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<journey>, [">= 0"])
|
|
101
|
-
s.add_development_dependency(%q<ruby-plsql>, [">= 0.4.4"])
|
|
102
|
-
s.add_development_dependency(%q<ruby-oci8>, [">= 2.0.4"])
|
|
103
|
-
else
|
|
104
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
|
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<journey>, [">= 0"])
|
|
113
|
-
s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
|
|
114
|
-
s.add_dependency(%q<ruby-oci8>, [">= 2.0.4"])
|
|
115
|
-
end
|
|
116
|
-
else
|
|
117
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
|
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<journey>, [">= 0"])
|
|
126
|
-
s.add_dependency(%q<ruby-plsql>, [">= 0.4.4"])
|
|
127
|
-
s.add_dependency(%q<ruby-oci8>, [">= 2.0.4"])
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# implementation idea taken from JDBC adapter
|
|
2
|
-
# added possibility to execute previously defined task (passed as argument to task block)
|
|
3
|
-
def redefine_task(*args, &block)
|
|
4
|
-
task_name = Hash === args.first ? args.first.keys[0] : args.first
|
|
5
|
-
existing_task = Rake.application.lookup task_name
|
|
6
|
-
existing_actions = nil
|
|
7
|
-
if existing_task
|
|
8
|
-
class << existing_task; public :instance_variable_set, :instance_variable_get; end
|
|
9
|
-
existing_task.instance_variable_set "@prerequisites", FileList[]
|
|
10
|
-
existing_actions = existing_task.instance_variable_get "@actions"
|
|
11
|
-
existing_task.instance_variable_set "@actions", []
|
|
12
|
-
end
|
|
13
|
-
task(*args) do
|
|
14
|
-
block.call(existing_actions)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Creates database user with db:create
|
|
19
|
-
if defined?(create_database) == 'method'
|
|
20
|
-
def create_database_with_oracle_enhanced(config)
|
|
21
|
-
if config['adapter'] == 'oracle_enhanced'
|
|
22
|
-
print "Please provide the SYSTEM password for your oracle installation\n>"
|
|
23
|
-
system_password = $stdin.gets.strip
|
|
24
|
-
ActiveRecord::Base.establish_connection(config.merge('username' => 'SYSTEM', 'password' => system_password))
|
|
25
|
-
begin
|
|
26
|
-
ActiveRecord::Base.connection.execute "CREATE USER #{config['username']} IDENTIFIED BY #{config['password']}"
|
|
27
|
-
rescue => e
|
|
28
|
-
if e.message =~ /ORA-01920/ # user name conflicts with another user or role name
|
|
29
|
-
ActiveRecord::Base.connection.execute "ALTER USER #{config['username']} IDENTIFIED BY #{config['password']}"
|
|
30
|
-
else
|
|
31
|
-
raise e
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
ActiveRecord::Base.connection.execute "GRANT unlimited tablespace TO #{config['username']}"
|
|
35
|
-
ActiveRecord::Base.connection.execute "GRANT create session TO #{config['username']}"
|
|
36
|
-
ActiveRecord::Base.connection.execute "GRANT create table TO #{config['username']}"
|
|
37
|
-
ActiveRecord::Base.connection.execute "GRANT create sequence TO #{config['username']}"
|
|
38
|
-
else
|
|
39
|
-
create_database_without_oracle_enhanced(config)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
alias :create_database_without_oracle_enhanced :create_database
|
|
43
|
-
alias :create_database :create_database_with_oracle_enhanced
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Drops database user with db:drop
|
|
47
|
-
if defined?(drop_database) == 'method'
|
|
48
|
-
def drop_database_with_oracle_enhanced(config)
|
|
49
|
-
if config['adapter'] == 'oracle_enhanced'
|
|
50
|
-
ActiveRecord::Base.establish_connection(config)
|
|
51
|
-
ActiveRecord::Base.connection.execute_structure_dump(ActiveRecord::Base.connection.full_drop)
|
|
52
|
-
else
|
|
53
|
-
drop_database_without_oracle_enhanced(config)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
alias :drop_database_without_oracle_enhanced :drop_database
|
|
57
|
-
alias :drop_database :drop_database_with_oracle_enhanced
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
namespace :db do
|
|
61
|
-
|
|
62
|
-
namespace :structure do
|
|
63
|
-
redefine_task :dump => :environment do |existing_actions|
|
|
64
|
-
abcs = ActiveRecord::Base.configurations
|
|
65
|
-
rails_env = defined?(Rails.env) ? Rails.env : RAILS_ENV
|
|
66
|
-
if abcs[rails_env]['adapter'] == 'oracle_enhanced'
|
|
67
|
-
ActiveRecord::Base.establish_connection(abcs[rails_env])
|
|
68
|
-
File.open("db/#{rails_env}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
|
69
|
-
if ActiveRecord::Base.connection.supports_migrations?
|
|
70
|
-
File.open("db/#{rails_env}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
|
|
71
|
-
end
|
|
72
|
-
if abcs[rails_env]['structure_dump'] == "db_stored_code"
|
|
73
|
-
File.open("db/#{rails_env}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.structure_dump_db_stored_code }
|
|
74
|
-
end
|
|
75
|
-
else
|
|
76
|
-
Array(existing_actions).each{|action| action.call}
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
namespace :test do
|
|
82
|
-
redefine_task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do |existing_actions|
|
|
83
|
-
abcs = ActiveRecord::Base.configurations
|
|
84
|
-
rails_env = defined?(Rails.env) ? Rails.env : RAILS_ENV
|
|
85
|
-
if abcs[rails_env]['adapter'] == 'oracle_enhanced' && abcs['test']['adapter'] == 'oracle_enhanced'
|
|
86
|
-
ActiveRecord::Base.establish_connection(:test)
|
|
87
|
-
ActiveRecord::Base.connection.execute_structure_dump(File.read("db/#{rails_env}_structure.sql"))
|
|
88
|
-
else
|
|
89
|
-
Array(existing_actions).each{|action| action.call}
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
redefine_task :purge => :environment do |existing_actions|
|
|
94
|
-
abcs = ActiveRecord::Base.configurations
|
|
95
|
-
if abcs['test']['adapter'] == 'oracle_enhanced'
|
|
96
|
-
ActiveRecord::Base.establish_connection(:test)
|
|
97
|
-
ActiveRecord::Base.connection.execute_structure_dump(ActiveRecord::Base.connection.full_drop)
|
|
98
|
-
ActiveRecord::Base.connection.execute("PURGE RECYCLEBIN") rescue nil
|
|
99
|
-
else
|
|
100
|
-
Array(existing_actions).each{|action| action.call}
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# ActiveRecord 2.3 patches
|
|
2
|
-
if ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 3
|
|
3
|
-
require "active_record/associations"
|
|
4
|
-
|
|
5
|
-
ActiveRecord::Associations::ClassMethods.module_eval do
|
|
6
|
-
private
|
|
7
|
-
def tables_in_string(string)
|
|
8
|
-
return [] if string.blank?
|
|
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
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation.class_eval do
|
|
20
|
-
protected
|
|
21
|
-
def aliased_table_name_for(name, suffix = nil)
|
|
22
|
-
# always downcase quoted table name as Oracle quoted table names are in uppercase
|
|
23
|
-
if !parent.table_joins.blank? && parent.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{active_record.connection.quote_table_name(name).downcase}\son}
|
|
24
|
-
@join_dependency.table_aliases[name] += 1
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
unless @join_dependency.table_aliases[name].zero?
|
|
28
|
-
# if the table name has been used, then use an alias
|
|
29
|
-
name = active_record.connection.table_alias_for "#{pluralize(reflection.name)}_#{parent_table_name}#{suffix}"
|
|
30
|
-
table_index = @join_dependency.table_aliases[name]
|
|
31
|
-
@join_dependency.table_aliases[name] += 1
|
|
32
|
-
name = name[0..active_record.connection.table_alias_length-3] + "_#{table_index+1}" if table_index > 0
|
|
33
|
-
else
|
|
34
|
-
@join_dependency.table_aliases[name] += 1
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
name
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
module ActiveRecord
|
|
2
|
-
class Base
|
|
3
|
-
# Establishes a connection to the database that's used by all Active Record objects.
|
|
4
|
-
def self.oracle_enhanced_connection(config) #:nodoc:
|
|
5
|
-
if config[:emulate_oracle_adapter] == true
|
|
6
|
-
# allows the enhanced adapter to look like the OracleAdapter. Useful to pick up
|
|
7
|
-
# conditionals in the rails activerecord test suite
|
|
8
|
-
require 'active_record/connection_adapters/emulation/oracle_adapter'
|
|
9
|
-
ConnectionAdapters::OracleAdapter.new(
|
|
10
|
-
ConnectionAdapters::OracleEnhancedConnection.create(config), logger, config)
|
|
11
|
-
else
|
|
12
|
-
ConnectionAdapters::OracleEnhancedAdapter.new(
|
|
13
|
-
ConnectionAdapters::OracleEnhancedConnection.create(config), logger, config)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Specify table columns which should be ignored by ActiveRecord, e.g.:
|
|
18
|
-
#
|
|
19
|
-
# ignore_table_columns :attribute1, :attribute2
|
|
20
|
-
def self.ignore_table_columns(*args)
|
|
21
|
-
connection.ignore_table_columns(table_name,*args)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Specify which table columns should be typecasted to Date (without time), e.g.:
|
|
25
|
-
#
|
|
26
|
-
# set_date_columns :created_on, :updated_on
|
|
27
|
-
def self.set_date_columns(*args)
|
|
28
|
-
connection.set_type_for_columns(table_name,:date,*args)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# Specify which table columns should be typecasted to Time (or DateTime), e.g.:
|
|
32
|
-
#
|
|
33
|
-
# set_datetime_columns :created_date, :updated_date
|
|
34
|
-
def self.set_datetime_columns(*args)
|
|
35
|
-
connection.set_type_for_columns(table_name,:datetime,*args)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Specify which table columns should be typecasted to boolean values +true+ or +false+, e.g.:
|
|
39
|
-
#
|
|
40
|
-
# set_boolean_columns :is_valid, :is_completed
|
|
41
|
-
def self.set_boolean_columns(*args)
|
|
42
|
-
connection.set_type_for_columns(table_name,:boolean,*args)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Specify which table columns should be typecasted to integer values.
|
|
46
|
-
# Might be useful to force NUMBER(1) column to be integer and not boolean, or force NUMBER column without
|
|
47
|
-
# scale to be retrieved as integer and not decimal. Example:
|
|
48
|
-
#
|
|
49
|
-
# set_integer_columns :version_number, :object_identifier
|
|
50
|
-
def self.set_integer_columns(*args)
|
|
51
|
-
connection.set_type_for_columns(table_name,:integer,*args)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Specify which table columns should be typecasted to string values.
|
|
55
|
-
# Might be useful to specify that columns should be string even if its name matches boolean column criteria.
|
|
56
|
-
#
|
|
57
|
-
# set_string_columns :active_flag
|
|
58
|
-
def self.set_string_columns(*args)
|
|
59
|
-
connection.set_type_for_columns(table_name,:string,*args)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# After setting large objects to empty, select the OCI8::LOB
|
|
63
|
-
# and write back the data.
|
|
64
|
-
if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR >= 1
|
|
65
|
-
before_update :record_changed_lobs
|
|
66
|
-
after_update :enhanced_write_lobs
|
|
67
|
-
else
|
|
68
|
-
before_update :record_changed_lobs
|
|
69
|
-
after_save :enhanced_write_lobs
|
|
70
|
-
end
|
|
71
|
-
def enhanced_write_lobs #:nodoc:
|
|
72
|
-
if connection.is_a?(ConnectionAdapters::OracleEnhancedAdapter) &&
|
|
73
|
-
!(self.class.custom_create_method || self.class.custom_update_method)
|
|
74
|
-
connection.write_lobs(self.class.table_name, self.class, attributes, @changed_lob_columns || self.class.lob_columns)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
def record_changed_lobs
|
|
78
|
-
@changed_lob_columns = self.class.lob_columns.select do |col|
|
|
79
|
-
self.class.serialized_attributes.keys.include?(col.name) ||
|
|
80
|
-
(self.send(:"#{col.name}_changed?") && !self.class.readonly_attributes.to_a.include?(col.name))
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
private :enhanced_write_lobs
|
|
84
|
-
private :record_changed_lobs
|
|
85
|
-
|
|
86
|
-
# Get table comment from schema definition.
|
|
87
|
-
def self.table_comment
|
|
88
|
-
connection.table_comment(self.table_name)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def self.lob_columns
|
|
92
|
-
columns.select do |column|
|
|
93
|
-
column.respond_to?(:lob?) && column.lob?
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def self.virtual_columns
|
|
98
|
-
columns.select do |column|
|
|
99
|
-
column.respond_to?(:virtual?) && column.virtual?
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
if ActiveRecord::VERSION::MAJOR < 3
|
|
104
|
-
def attributes_with_quotes_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
|
|
105
|
-
virtual_column_names = self.class.virtual_columns.map(&:name)
|
|
106
|
-
attributes_with_quotes_without_virtual_columns(include_primary_key, include_readonly_attributes, attribute_names - virtual_column_names)
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
alias_method_chain :attributes_with_quotes, :virtual_columns
|
|
110
|
-
else
|
|
111
|
-
def arel_attributes_values_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
|
|
112
|
-
virtual_column_names = self.class.virtual_columns.map(&:name)
|
|
113
|
-
arel_attributes_values_without_virtual_columns(include_primary_key, include_readonly_attributes, attribute_names - virtual_column_names)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
alias_method_chain :arel_attributes_values, :virtual_columns
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
end
|