Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 ORM Failing with fields containing a - #2732

Closed
Grafikart opened this issue Jan 29, 2014 · 1 comment
Closed

3.0 ORM Failing with fields containing a - #2732

Grafikart opened this issue Jan 29, 2014 · 1 comment
Labels
Milestone

Comments

@Grafikart
Copy link
Contributor

I have a field in my database (MySQL) called 'video-size'
When I try to get that field the SQL generated queries does

SELECT Tutoriels.video-size AS `Tutoriels__video-size` FROM tutoriels AS Tutoriels'

One solution would be to surround every fields (or only fields containing -) with '

SELECT Tutoriels.`video-size` AS `Tutoriels__video-size` FROM tutoriels AS Tutoriels

Another solution is to throw an error explaining that the database should not contain such a field since it will cause lots of trouble like "how to get that field from entity"

$entity->get('video-size') // Does this would work ?
$entity->video-size        // Since this will never work 
@lorenzo
Copy link
Member

lorenzo commented Jan 29, 2014

Cake 3.0 will do as little as possible to quote your database names and column names. If you really need to use invalid SQL names you can use quoteIdentifiers as described in the docs, in that case $entity->get('video-size') would work fine, but as you figured out with the $entity->video-size, it makes much more sense to stick in the safe side of sql.

@lorenzo lorenzo closed this as completed Jan 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants