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
Quoted DB expression when used in param #6382
Comments
Debug tool should be adjusted. |
Well, it is a bug, not a feature : DB expression should not be quoted |
Yes, that is true as well. |
Corect me, MyModel::deleteAll("expire < NOW()");
// or
MyModel::deleteAll(['<','expire',new Expression('NOW()')]); Sory for my english |
We should not care about pdo/yii here, and the three should be logically the same : MyModel::deleteAll("expire < NOW()");
MyModel::deleteAll(['<','expire',new Expression('NOW()')]);
MyModel::deleteAll("expire < :expire", [':expire' => new Expression('NOW()')]); |
Where did you get this from? |
From mysql server log (since yii debug doesn't show the real query) PS : test_expire was a typo of course |
Ideally yes. But to handle this, yii must create his own parser. I am neutral here. |
As explained by @mdmunir, this is expected behavior since you are using parameter binding, a native feature of PDO. The DB expression will be converted into a string before being bound to the parameter. We can't do anything about this. The debug tool should be adjusted to reflect the true SQL being executed. |
There should be at least an InvalidParamException |
Nope. It is good as is. We just need to fix the debug tool display if the issue is verified. |
I don't see the meaning of binding a db expression if it is quoted after, there should be an exception. |
I suspect this is because yii\db\mysql\QueryBuilder:183 is looking for Expression in the current namespace (\yii\db\mysql), but the class actually exists in \yii\db, so that instanceof check always fails. Can somebody fix that to either fully qualify Expression or use it? |
Issue moved to yiisoft/yii2-debug#78 |
Hello
DB Expression is quoted when used in param, e.g.
This will make the following query :
Be careful, debug tool will log the correct one :
http://stackoverflow.com/questions/27312579/odd-behavior-of-now-and-db-expression-in-yii2-mysql
The text was updated successfully, but these errors were encountered: