Migration command 'rename_column' broken with ActiveRecord-JDBC 0.6, MySQL 5.0
and Rails 1.2.3
----------------------------------------------------------------------------------------------
Key: JRUBY-1543
URL: http://jira.codehaus.org/browse/JRUBY-1543
Project: JRuby
Issue Type: Bug
Components: ActiveRecord-JDBC
Affects Versions: JRuby 1.0.2
Environment: Ubuntu 7.04, Java 1.6, JRuby 1.0.2, Rails 1.2.3,
ActiveRecord-JDBC 0.6 (using "adapter: jdbc"), MySQL 5.0.45,
mysql-connector-java-5.1.5-bin.jar
Reporter: Oliver Schmelzle
Running migrations that contain the command 'rename_column' with
ActiveRecord-JDBC 0.6 and MySQL 5.0.45 triggered the following exception:
"ArgumentError: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1: ALTER TABLE table_name CHANGE old_name new_name"
The code triggering this exception is in the file
activerecord-jdbc-adapter-0.6/lib/jdbc_adapter/jdbc_mysql.rb
...
def rename_column(table_name, column_name, new_column_name) #:nodoc:
current_type = select_one("SHOW COLUMNS FROM #{table_name} LIKE
'#{column_name}'")["Type"]
execute "ALTER TABLE #{table_name} CHANGE #{column_name}
#{new_column_name} #{current_type}"
end
...
It appears the hash that select_one returns doesn't contain a key called
"Type". Once the right key "COLUMN_TYPE" is used this migration command works
flawlessly.
Here the proposed change:
...
current_type = select_one("SHOW COLUMNS FROM #{table_name} LIKE
'#{column_name}'")["COLUMN_TYPE"]
...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email