Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7850 (closed defect: duplicate)

Opened 2 years ago

Last modified 2 years ago

[PATCH] Added missing backticks to mysql adapter

Reported by: sole Assigned to: core
Priority: normal Milestone: 1.x
Component: ActiveRecord Version: 1.2.3
Severity: normal Keywords:
Cc:

Description

Because column names aren't backticked by default, using any mysql reserved name for the columns can end in an error like this one:

-- change_column(:my_configs, :key, :string, {:limit=>32, :null=>false}) rake aborted! Mysql::Error: 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 'key key varchar(32) NOT NULL' at line 1: ALTER TABLE my_configs CHANGE key key varchar(32) NOT NULL

I patched mysql_adapter.rb so that it now has backticks surrounding the column names in the methods for handling columns. Now I can run migrations using mysql's reserved words as column names.

Attachments

add_backticks_for_columns_in_migrations_patch.diff (1.8 kB) - added by sole on 03/16/07 22:18:11.

Change History

03/16/07 22:18:11 changed by sole

  • attachment add_backticks_for_columns_in_migrations_patch.diff added.

03/17/07 00:19:19 changed by josh

  • keywords set to tiny.

03/17/07 18:17:24 changed by josh

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to duplicate.

Duplicate of #4905.