1
- require 'arjdbc/jdbc/serialized_attributes_helper '
1
+ require 'arjdbc/util/serialized_attributes '
2
2
3
3
module ArJdbc
4
4
module Informix
5
-
5
+
6
6
@@_lob_callback_added = nil
7
-
7
+
8
8
def self . extended ( base )
9
9
unless @@_lob_callback_added
10
10
ActiveRecord ::Base . class_eval do
@@ -13,10 +13,10 @@ def after_save_with_informix_lob
13
13
lob_columns . each do |column |
14
14
value = ::ArJdbc ::SerializedAttributesHelper . dump_column_value ( self , column )
15
15
next if value . nil? || ( value == '' )
16
-
16
+
17
17
connection . write_large_object (
18
- column . type == :binary , column . name ,
19
- self . class . table_name , self . class . primary_key ,
18
+ column . type == :binary , column . name ,
19
+ self . class . table_name , self . class . primary_key ,
20
20
quote_value ( id ) , value
21
21
)
22
22
end
@@ -28,16 +28,25 @@ def after_save_with_informix_lob
28
28
end
29
29
end
30
30
31
+ # @see ActiveRecord::ConnectionAdapters::JdbcColumn#column_types
31
32
def self . column_selector
32
- [ /informix/i , lambda { |cfg , column | column . extend ( :: ArJdbc :: Informix :: Column ) } ]
33
+ [ /informix/i , lambda { |cfg , column | column . extend ( ColumnMethods ) } ]
33
34
end
34
35
36
+ JdbcConnection = ::ActiveRecord ::ConnectionAdapters ::InformixJdbcConnection
37
+
38
+ # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
35
39
def self . jdbc_connection_class
36
40
::ActiveRecord ::ConnectionAdapters ::InformixJdbcConnection
37
41
end
38
42
39
- module Column
40
-
43
+ # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_column_class
44
+ def jdbc_column_class
45
+ ::ActiveRecord ::ConnectionAdapters ::InformixColumn
46
+ end
47
+
48
+ module ColumnMethods
49
+
41
50
private
42
51
# TODO: Test all Informix column types.
43
52
def simplified_type ( field_type )
@@ -47,7 +56,7 @@ def simplified_type(field_type)
47
56
super
48
57
end
49
58
end
50
-
59
+
51
60
end
52
61
53
62
def modify_types ( types )
@@ -126,18 +135,28 @@ def drop_table(name)
126
135
def remove_index ( table_name , options = { } )
127
136
@connection . execute_update ( "DROP INDEX #{ index_name ( table_name , options ) } " )
128
137
end
129
-
138
+
130
139
def select ( sql , *rest )
131
140
# Informix does not like "= NULL", "!= NULL", or "<> NULL".
132
- execute ( sql . gsub ( /(!=|<>)\s *null/i , "IS NOT NULL" ) . gsub ( /=\s *null/i , "IS NULL" ) , *rest )
141
+ super ( sql . gsub ( /(!=|<>)\s *null/i , "IS NOT NULL" ) . gsub ( /=\s *null/i , "IS NULL" ) , *rest )
133
142
end
134
-
143
+
135
144
private
136
-
145
+
137
146
def db_major_version
138
- @@db_major_version ||=
147
+ @@db_major_version ||=
139
148
select_one ( "SELECT dbinfo('version', 'major') version FROM systables WHERE tabid = 1" ) [ 'version' ] . to_i
140
149
end
141
-
150
+
142
151
end # module Informix
143
152
end # module ::ArJdbc
153
+
154
+ module ActiveRecord ::ConnectionAdapters
155
+ class InformixColumn < JdbcColumn
156
+ include ::ArJdbc ::Informix ::ColumnMethods
157
+ end
158
+
159
+ class InformixAdapter < JdbcAdapter
160
+ include ::ArJdbc ::Informix
161
+ end
162
+ end
0 commit comments