Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

'key' column name getting interpreted at MySQL keyword KEY #98

Closed
jedgalbraith opened this issue Apr 1, 2013 · 3 comments
Closed

'key' column name getting interpreted at MySQL keyword KEY #98

jedgalbraith opened this issue Apr 1, 2013 · 3 comments

Comments

@jedgalbraith
Copy link

I'm attempting to load data into the oauth_consumer table via a fixture (https://gist.github.com/jedgalbraith/5286238#file-fixture-yaml-L2).

I'm getting a MySQL syntax error due to the 'key' column in the 'ON DUPLICATE KEY UPDATE' portion of the query. The 'key' column is getting interpreted as the MySQL reserved keyword, 'KEY'. (https://gist.github.com/jedgalbraith/5286238#file-query-original-sql-L8)

If I manually add back ticks around key in the query and run it directly in MySQL, it runs correctly. (https://gist.github.com/jedgalbraith/5286238#file-query-edit-sql-L8)

Any ideas how to get back ticks around the key column name or otherwise get around this?

@jedgalbraith
Copy link
Author

From what I've found out so far, this appears to be more of an issue with Magento/Varien core than with EcomDev_PHPUnit directly.

As a temporary workaround I've overridden the file at app/code/local/Varien/Db/Adapter/Pdo/Mysql.php:1901 and added backticks:
$updateFields[] = sprintf('%s = %s', $field, $value);

Feel free to close this if you also agree with my assessment.

@IvanChepurnyi
Copy link
Member

Yeap, totally agree. Maybe it is better for you just change the name of column to not conflict with mysql keywords?

@jedgalbraith
Copy link
Author

If I changed the name of the column, I'd also have to modify all the references to it in the Mage_Oauth module. But, regardless, not an EcomDev_PHPUnit issue, so I'll close this out. Thanks for the response.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants