Skip to content

Commit 160c48a

Browse files
committed
[mysql] make sure new_column works - we now export a MySQL::Column constant
1 parent a02e8d2 commit 160c48a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/arjdbc/mysql/adapter.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,15 @@ def columns(table_name, name = nil)
357357
sql = "SHOW FULL COLUMNS FROM #{quote_table_name(table_name)}"
358358
columns = execute(sql, name || 'SCHEMA')
359359
strict = strict_mode?
360-
column = ::ActiveRecord::ConnectionAdapters::MysqlAdapter::Column
361360
pass_cast_type = respond_to?(:lookup_cast_type)
362361
columns.map! do |field|
363362
sql_type = field['Type']
364363
null = field['Null'] == "YES"
365364
if pass_cast_type
366365
cast_type = lookup_cast_type(sql_type)
367-
column.new(field['Field'], field['Default'], cast_type, sql_type, null, field['Collation'], strict, field['Extra'])
366+
Column.new(field['Field'], field['Default'], cast_type, sql_type, null, field['Collation'], strict, field['Extra'])
368367
else
369-
column.new(field['Field'], field['Default'], sql_type, null, field['Collation'], strict, field['Extra'])
368+
Column.new(field['Field'], field['Default'], sql_type, null, field['Collation'], strict, field['Extra'])
370369
end
371370
end
372371
columns
@@ -653,7 +652,7 @@ class Column < JdbcColumn
653652
include ::ArJdbc::MySQL::Column
654653

655654
def initialize(name, default, sql_type = nil, null = true, collation = nil, strict = false, extra = '')
656-
if Hash === name
655+
if name.is_a?(Hash)
657656
super # first arg: config
658657
else
659658
@strict = strict; @collation = collation; @extra = extra
@@ -663,7 +662,7 @@ def initialize(name, default, sql_type = nil, null = true, collation = nil, stri
663662
end
664663

665664
def initialize(name, default, cast_type, sql_type = nil, null = true, collation = nil, strict = false, extra = '')
666-
if Hash === name
665+
if name.is_a?(Hash)
667666
super # first arg: config
668667
else
669668
@strict = strict; @collation = collation; @extra = extra
@@ -711,3 +710,9 @@ def jdbc_column_class
711710

712711
end
713712
end
713+
714+
module ArJdbc
715+
module MySQL
716+
Column = ::ActiveRecord::ConnectionAdapters::MysqlAdapter::Column
717+
end
718+
end

0 commit comments

Comments
 (0)