activerecord-oracle_enhanced-adapter 1.4.3 → 1.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/History.md +51 -0
- data/README.md +32 -1
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -4
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +315 -57
- data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +55 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +4 -13
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +5 -6
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +19 -11
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +163 -232
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +18 -10
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +20 -32
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +54 -35
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +5 -74
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +3 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +98 -98
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +5 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +11 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +56 -55
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +15 -8
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +4 -3
- data/spec/spec_helper.rb +25 -54
- metadata +32 -20
- 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_tasks.rb +0 -17
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.
|
4
|
+
version: 1.5.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeweler
|
@@ -58,84 +58,98 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 4.0.1.rc3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 4.0.1.rc3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: actionpack
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 4.0.1.rc3
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 4.0.1.rc3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 4.0.1.rc3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 4.0.1.rc3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: railties
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 4.0.1.rc3
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 4.0.1.rc3
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activerecord-deprecated_finders
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: ruby-plsql
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - '>='
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
131
|
+
version: 0.5.0
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - '>='
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
138
|
+
version: 0.5.0
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: ruby-oci8
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - '>='
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.
|
145
|
+
version: 2.1.2
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - '>='
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 2.
|
152
|
+
version: 2.1.2
|
139
153
|
description: |
|
140
154
|
Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
141
155
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
@@ -156,10 +170,9 @@ files:
|
|
156
170
|
- activerecord-oracle_enhanced-adapter.gemspec
|
157
171
|
- lib/active_record/connection_adapters/emulation/oracle_adapter.rb
|
158
172
|
- lib/active_record/connection_adapters/oracle_enhanced.rake
|
159
|
-
- lib/active_record/connection_adapters/oracle_enhanced_activerecord_patches.rb
|
160
173
|
- lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
|
161
|
-
- lib/active_record/connection_adapters/oracle_enhanced_base_ext.rb
|
162
174
|
- lib/active_record/connection_adapters/oracle_enhanced_column.rb
|
175
|
+
- lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb
|
163
176
|
- lib/active_record/connection_adapters/oracle_enhanced_connection.rb
|
164
177
|
- lib/active_record/connection_adapters/oracle_enhanced_context_index.rb
|
165
178
|
- lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb
|
@@ -173,7 +186,6 @@ files:
|
|
173
186
|
- lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb
|
174
187
|
- lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb
|
175
188
|
- lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb
|
176
|
-
- lib/active_record/connection_adapters/oracle_enhanced_tasks.rb
|
177
189
|
- lib/active_record/connection_adapters/oracle_enhanced_version.rb
|
178
190
|
- lib/activerecord-oracle_enhanced-adapter.rb
|
179
191
|
- spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
|
@@ -204,12 +216,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
216
|
version: '0'
|
205
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
218
|
requirements:
|
207
|
-
- - '
|
219
|
+
- - '>'
|
208
220
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
221
|
+
version: 1.3.1
|
210
222
|
requirements: []
|
211
223
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.1.
|
224
|
+
rubygems_version: 2.1.10
|
213
225
|
signing_key:
|
214
226
|
specification_version: 4
|
215
227
|
summary: Oracle enhanced adapter for ActiveRecord
|
@@ -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
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# Used just for Rails 2.x
|
2
|
-
# In Rails 3.x rake tasks are loaded using railtie
|
3
|
-
if ActiveRecord::VERSION::MAJOR == 2
|
4
|
-
|
5
|
-
if defined?(Rake.application) && Rake.application &&
|
6
|
-
ActiveRecord::Base.configurations[defined?(Rails.env) ? Rails.env : RAILS_ENV]['adapter'] == 'oracle_enhanced'
|
7
|
-
oracle_enhanced_rakefile = File.dirname(__FILE__) + "/oracle_enhanced.rake"
|
8
|
-
if Rake.application.lookup("environment")
|
9
|
-
# rails tasks already defined; load the override tasks now
|
10
|
-
load oracle_enhanced_rakefile
|
11
|
-
else
|
12
|
-
# rails tasks not loaded yet; load as an import
|
13
|
-
Rake.application.add_import(oracle_enhanced_rakefile)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|