Currently, query builder always attempts to quote table and column names whenever possible. For example, for MySQL, $command->select()->from(‘tbl_user’) will generate SELECT * FROM
tbl_user, where the table name is automatically quoted.
Unfortunately, auotoquoting is incomplete. For example, it doesn’t autoquote for table/column names appearing in a WHERE condition. Also, auotoquoting may cause some troubles and require workaround to overcome these troubles (for example, select(‘2’) needs to be written as select(’(2)’) to avoid incorrect quoting).
So should we keep this feature in 2.0?
I haven’t run into any trouble with it yet, but even if I take into account the fact that it can be buggy at some occurrences, you should keep it. Why? Take a table witch has a field named “date” or any other keyword - if you don’t quote it into
in MySQL - you have a failed SQL query. And I have banged and keep banging my head into this on and on
I believe CDbCriteria, query builder and AR can be enhanced/changed in a way that will make auto quoting easier, so it can quote in WHERE statements too. Quoting in the CDbCriteria::condition string is of course the user’s problem
I ran into some problems regarding autoquoting. Nothing I couldn’t work around, yet there were situations where I wished I could turn it off.
As I am used to include backticks into my queries, the last option is definitely my favourite. But I can see how others are used to this feature. Making it configurable (preferably per query) should be the way to go
Actually it would be good to see the examples where the auto quoting is breaking something or unable to function properly. It could lead to a discussion how to fix it or make better.
As I understand it usually fails when you do customized queries. I tend to use AR with CDbCriteria and avoid using it’s condition property as much as I can (CDbCriteria mostly provides the methods I need like addColumnInCondition and others), so I haven’t yet run into problems, but would like to review them for academic purposes and probably providing a patch.
Hm, I’m afraid I cannot provide any hands-on examples. I only remember I did run into problems. I think it had to do with IS NULL checks in the conditions.
Most of the time it’s useful but sometimes, in complex cases, you want just to turn if off and do quoting manually.
It should be configurable, for the whole application and per query, but defaults to "yes".
Should be based on the principle of least amount of surprises.
Thank you all for expressing your preference. Decision made -> [color=#1C2837]Make it configurable and default to Yes[/color]