@@ -41,8 +41,26 @@ def jdbc_connection_class
41
41
def new_client ( conn_params , adapter_instance )
42
42
jdbc_connection_class . new ( conn_params , adapter_instance )
43
43
end
44
+
45
+ private
46
+ def initialize_type_map ( m )
47
+ super
48
+
49
+ m . register_type ( %r(char)i ) do |sql_type |
50
+ limit = extract_limit ( sql_type )
51
+ Type . lookup ( :string , adapter : :mysql2 , limit : limit )
52
+ end
53
+
54
+ m . register_type %r(^enum)i , Type . lookup ( :string , adapter : :mysql2 )
55
+ m . register_type %r(^set)i , Type . lookup ( :string , adapter : :mysql2 )
56
+ end
44
57
end
45
58
59
+ # NOTE: redefines constant defined in abstract class however this time
60
+ # will use methods defined in the mysql abstract class and map properly
61
+ # mysql types.
62
+ TYPE_MAP = Type ::TypeMap . new . tap { |m | initialize_type_map ( m ) }
63
+
46
64
def initialize ( ...)
47
65
super
48
66
@@ -58,11 +76,6 @@ def initialize(...)
58
76
@connection_parameters ||= @config
59
77
end
60
78
61
- # NOTE: redefines constant defined in abstract class however this time
62
- # will use methods defined in the mysql abstract class and map properly
63
- # mysql types.
64
- TYPE_MAP = Type ::TypeMap . new . tap { |m | initialize_type_map ( m ) }
65
-
66
79
def self . database_exists? ( config )
67
80
conn = ActiveRecord ::Base . mysql2_connection ( config )
68
81
conn && conn . really_valid?
0 commit comments