oracle-enhanced-enhanced 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -2,9 +2,6 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters
|
3
3
|
class OracleEnhancedAdapter
|
4
4
|
|
5
|
-
# Set our new enhanced defaults
|
6
|
-
set_enhanced_defaults
|
7
|
-
|
8
5
|
# Maximum length of an Oracle VARCHAR2 field
|
9
6
|
VARCHAR2_MAX_LENGTH = 4000
|
10
7
|
|
@@ -14,7 +11,7 @@ module ActiveRecord
|
|
14
11
|
NATIVE_DATABASE_TYPES[:text] = use_varchar2 ? {:name => 'VARCHAR2', :limit => length} : {:name => 'CLOB'}
|
15
12
|
end
|
16
13
|
|
17
|
-
# Create convenience methods to check what storage representation is in effect
|
14
|
+
# Create convenience methods to check what text storage representation is in effect
|
18
15
|
# e.g. text_is_clob?, text_is_varchar2?
|
19
16
|
%w(clob varchar2).each do |format|
|
20
17
|
(class << self; self; end).instance_eval do
|
@@ -24,44 +21,51 @@ module ActiveRecord
|
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
27
|
-
# Convert an existing CLOB field into a VARCHAR2. For use in migrations.
|
28
|
-
def convert_clob_to_varchar2(table_name, column_name, varchar2_length = VARCHAR2_MAX_LENGTH, temp_column_name = nil)
|
29
|
-
convert_text_column_storage_type table_name, column_name, "varchar2#{varchar2_length}", temp_column_name
|
30
|
-
end
|
31
|
-
|
32
|
-
# Convert an existing VARCHAR2 field into a CLOB. For use in migrations.
|
33
|
-
def convert_varchar2_to_clob(table_name, column_name, temp_column_name = nil)
|
34
|
-
convert_text_column_storage_type table_name, column_name, 'clob', temp_column_name
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
24
|
# Enable our enhanced settings/defaults
|
40
|
-
def set_enhanced_defaults
|
25
|
+
def self.set_enhanced_defaults
|
41
26
|
# Use varchar2(4000) for TEXT fields
|
42
27
|
set_text_storage_representation true
|
43
28
|
|
44
29
|
# Cache columns because we don't need to hit the database to check metadata all the time
|
30
|
+
#TODO: should we disable this for development?
|
45
31
|
self.cache_columns = true
|
46
32
|
|
47
33
|
# Oracle's default sequence behavious doesn't appeal to us OCD freaks who prefer monotonically increasing sequences
|
48
34
|
self.default_sequence_start_value = "1 NOCACHE ORDER"
|
49
35
|
end
|
50
36
|
|
37
|
+
# Enable the enhanced defaults
|
38
|
+
set_enhanced_defaults
|
39
|
+
end
|
40
|
+
|
41
|
+
module SchemaStatements
|
42
|
+
# Convert an existing CLOB field into a VARCHAR2. For use in migrations.
|
43
|
+
def convert_clob_to_varchar2(table_name, column_name, varchar2_length = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::VARCHAR2_MAX_LENGTH, temp_column_name = nil)
|
44
|
+
convert_text_column_storage_type table_name, column_name, "varchar2(#{varchar2_length})", temp_column_name
|
45
|
+
end
|
46
|
+
|
47
|
+
# Convert an existing VARCHAR2 field into a CLOB. For use in migrations.
|
48
|
+
def convert_varchar2_to_clob(table_name, column_name, temp_column_name = nil)
|
49
|
+
convert_text_column_storage_type table_name, column_name, 'clob', temp_column_name
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
51
54
|
# Convert a field from varchar2 to clob or vice versa
|
52
55
|
def convert_text_column_storage_type(table_name, column_name, to_type, temp_column_name)
|
53
|
-
|
54
|
-
|
56
|
+
quoted_table_name = quote_table_name(table_name)
|
57
|
+
orig_col = quote_column_name(column_name)
|
58
|
+
temp_col = quote_column_name(temp_column_name || 'oee_temp_col')
|
55
59
|
cmds = <<-SQL
|
56
|
-
alter table #{
|
57
|
-
update #{
|
58
|
-
|
59
|
-
alter table #{
|
60
|
-
alter table #{table_name} modify #{column_name} #{to_type}
|
61
|
-
update #{table_name} set #{column_name} = #{temp_col}
|
62
|
-
alter table #{table_name} drop column #{temp_col}
|
60
|
+
alter table #{quoted_table_name} add #{temp_col} #{to_type}
|
61
|
+
update #{quoted_table_name} set #{temp_col} = #{orig_col}
|
62
|
+
alter table #{quoted_table_name} drop column #{orig_col}
|
63
|
+
alter table #{quoted_table_name} rename column #{temp_col} to #{orig_col}
|
63
64
|
SQL
|
64
|
-
cmds.split(
|
65
|
+
cmds.split("\n").map(&:strip).each{|cmd| execute cmd}
|
66
|
+
|
67
|
+
# Also process any history table
|
68
|
+
convert_text_column_storage_type(history_table_name(table_name), column_name, to_type, temp_column_name) if history_table_exists?(table_name)
|
65
69
|
end
|
66
70
|
end
|
67
71
|
|
@@ -9,8 +9,12 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Steve Lamotte"]
|
10
10
|
s.email = ["slamotte@winnipeg.ca"]
|
11
11
|
s.homepage = "http://gems.winnipegtransit.org"
|
12
|
-
s.summary = %q{Additional enhancements/customizations to the Oracle Enhanced adapter}
|
13
|
-
s.description =
|
12
|
+
s.summary = %q{Additional enhancements/customizations to the excellent ActiveRecord Oracle Enhanced adapter}
|
13
|
+
s.description = <<-END
|
14
|
+
This gem includes several enhancements and customizations to the standard ActiveRecord Oracle Enhanced adapter, which is still required.
|
15
|
+
|
16
|
+
Any customizations to this adapter's behaviour or additional Oracle-specific utilities should be added here.
|
17
|
+
END
|
14
18
|
|
15
19
|
s.rubyforge_project = "oracle-enhanced-enhanced"
|
16
20
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oracle-enhanced-enhanced
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve Lamotte
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-16 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,11 @@ dependencies:
|
|
32
32
|
version: "0"
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
|
-
description:
|
35
|
+
description: |
|
36
|
+
This gem includes several enhancements and customizations to the standard ActiveRecord Oracle Enhanced adapter, which is still required.
|
37
|
+
|
38
|
+
Any customizations to this adapter's behaviour or additional Oracle-specific utilities should be added here.
|
39
|
+
|
36
40
|
email:
|
37
41
|
- slamotte@winnipeg.ca
|
38
42
|
executables: []
|
@@ -46,7 +50,7 @@ files:
|
|
46
50
|
- Gemfile
|
47
51
|
- Gemfile.lock
|
48
52
|
- Rakefile
|
49
|
-
- lib/
|
53
|
+
- lib/oracle-enhanced-enhanced.rb
|
50
54
|
- lib/oracle-enhanced-enhanced/version.rb
|
51
55
|
- oracle-enhanced-enhanced.gemspec
|
52
56
|
has_rdoc: true
|
@@ -82,6 +86,6 @@ rubyforge_project: oracle-enhanced-enhanced
|
|
82
86
|
rubygems_version: 1.3.7
|
83
87
|
signing_key:
|
84
88
|
specification_version: 3
|
85
|
-
summary: Additional enhancements/customizations to the Oracle Enhanced adapter
|
89
|
+
summary: Additional enhancements/customizations to the excellent ActiveRecord Oracle Enhanced adapter
|
86
90
|
test_files: []
|
87
91
|
|