
Quoting of name on mysql
Reported by ahto | October 4th, 2010 @ 09:05 AM | in 1.1
I'm currently running MySQL 5.1.41 and datamapper gems (versions 1.0.2) and I'm having problems using constraints.
I'm no expert but I'm guessing it has to do with the way names
are quoted.
For example here is a debug output of the first query that fails
with mysql complaining about the syntax.
SELECT COUNT(*) FROM "information_schema"."table_constraints" WHERE "constraint_type" = 'FOREIGN KEY' AND "table_schema" = 'ultra_dev' AND "table_name" = 'subscriptions' AND "constraint_name" = 'subscriptions_account_fk'
As you can see the names are quoted using normal double quotes and when they are replaced by ` the query runs ok.
Example that works
SELECT COUNT(*) FROM `information_schema`.`table_constraints` WHERE `constraint_type` = 'FOREIGN KEY' AND `table_schema` = 'ultra_dev' AND `table_name` = 'subscriptions' AND `constraint_name` = 'subscriptions_account_fk'
Comments and changes to this ticket
-
-
Piotr Solnica (solnic) March 9th, 2011 @ 06:37 AM
- State changed from new to confirmed
- Milestone set to 1.1
- Assigned user set to Piotr Solnica (solnic)
- Milestone order changed from 196295 to 0
-
Piotr Solnica (solnic) March 9th, 2011 @ 07:35 AM
- State changed from confirmed to resolved
(from [605d3cdd8c583754296ebc49ba119c188b231695]) Quote names when checking if a constraint exists
[#1427 state:resolved] https://github.com/datamapper/dm-constraints/commit/605d3cdd8c58375...
-
Dan Kubb (dkubb) March 9th, 2011 @ 09:43 AM
I wonder why this would cause problems? DO explicitly sets The ANSI_QUOTES ( http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode... ) sql-mode so that double quotes works.
Granted we've changed things in DM so that we now use backticks to quote identifiers, but the reason for that wasn't because it didn't work (it worked fine), it was when people tried to test the query by cutting/pasting it into a MySQL client it wouldn't work until they replaced the double quotes with backticks. Not many people set their sql-mode directly.
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Tags
Referenced by
-
1427 Quoting of name on mysql [#1427 state:resolved] https://github.com/datamapper/dm-...