pmacs-activerecord-oracle_enhanced-adapter 1.4.2.rc1 → 1.5.5.1
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 +7 -0
- data/Gemfile +11 -40
- data/History.md +170 -0
- data/README.md +61 -5
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +330 -161
- data/lib/active_record/connection_adapters/oracle_enhanced_column.rb +48 -8
- data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +77 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_connection.rb +8 -24
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +4 -13
- data/lib/active_record/connection_adapters/oracle_enhanced_database_tasks.rb +61 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +13 -12
- data/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +42 -19
- data/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +28 -74
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +165 -231
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_creation.rb +89 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +16 -24
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_dumper.rb +29 -38
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +93 -42
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +5 -3
- data/lib/active_record/connection_adapters/oracle_enhanced_structure_dump.rb +7 -7
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +1 -1
- data/lib/pmacs-activerecord-oracle_enhanced-adapter.rb +2 -2
- data/pmacs-activerecord-oracle_enhanced-adapter.gemspec +19 -17
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +35 -99
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +17 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +105 -98
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +74 -44
- data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +89 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +13 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +11 -12
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +252 -60
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +170 -40
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +14 -8
- data/spec/spec_helper.rb +25 -54
- metadata +41 -72
- 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 -118
- data/lib/active_record/connection_adapters/oracle_enhanced_core_ext.rb +0 -25
- data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +0 -17
- data/spec/active_record/connection_adapters/oracle_enhanced_core_ext_spec.rb +0 -19
@@ -1,118 +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{|col| self.send(:"#{col.name}_changed?") && !self.class.readonly_attributes.to_a.include?(col.name)}
|
79
|
-
end
|
80
|
-
private :enhanced_write_lobs
|
81
|
-
private :record_changed_lobs
|
82
|
-
|
83
|
-
# Get table comment from schema definition.
|
84
|
-
def self.table_comment
|
85
|
-
connection.table_comment(self.table_name)
|
86
|
-
end
|
87
|
-
|
88
|
-
def self.lob_columns
|
89
|
-
columns.select do |column|
|
90
|
-
column.respond_to?(:lob?) && column.lob?
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.virtual_columns
|
95
|
-
columns.select do |column|
|
96
|
-
column.respond_to?(:virtual?) && column.virtual?
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
if ActiveRecord::VERSION::MAJOR < 3
|
101
|
-
def attributes_with_quotes_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
|
102
|
-
virtual_column_names = self.class.virtual_columns.map(&:name)
|
103
|
-
attributes_with_quotes_without_virtual_columns(include_primary_key, include_readonly_attributes, attribute_names - virtual_column_names)
|
104
|
-
end
|
105
|
-
|
106
|
-
alias_method_chain :attributes_with_quotes, :virtual_columns
|
107
|
-
else
|
108
|
-
def arel_attributes_values_with_virtual_columns(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys)
|
109
|
-
virtual_column_names = self.class.virtual_columns.map(&:name)
|
110
|
-
arel_attributes_values_without_virtual_columns(include_primary_key, include_readonly_attributes, attribute_names - virtual_column_names)
|
111
|
-
end
|
112
|
-
|
113
|
-
alias_method_chain :arel_attributes_values, :virtual_columns
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require "bigdecimal"
|
2
|
-
|
3
|
-
unless BigDecimal.method_defined?(:to_d)
|
4
|
-
BigDecimal.class_eval do
|
5
|
-
def to_d #:nodoc:
|
6
|
-
self
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
unless Bignum.method_defined?(:to_d)
|
12
|
-
Bignum.class_eval do
|
13
|
-
def to_d #:nodoc:
|
14
|
-
BigDecimal.new(self.to_s)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
unless Fixnum.method_defined?(:to_d)
|
20
|
-
Fixnum.class_eval do
|
21
|
-
def to_d #:nodoc:
|
22
|
-
BigDecimal.new(self.to_s)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
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
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "OracleEnhancedAdapter to_d method" do
|
5
|
-
it "BigDecimal#to_d returns the same decimal number" do
|
6
|
-
d = BigDecimal.new("12345678901234567890.0123456789")
|
7
|
-
d.to_d.should == d
|
8
|
-
end
|
9
|
-
|
10
|
-
it "Bignum#to_d translates large integer to decimal" do
|
11
|
-
n = 12345678901234567890
|
12
|
-
n.to_d.should == BigDecimal.new(n.to_s)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "Fixnum#to_d translates small integer to decimal" do
|
16
|
-
n = 123456
|
17
|
-
n.to_d.should == BigDecimal.new(n.to_s)
|
18
|
-
end
|
19
|
-
end
|