Closed scottfriebel closed 3 years ago
I think this is as expected. I'm not aware that field = !whatever
is correct SQL syntax too.
Basically expression is expression - it just renders as such and no additional logic should be in there.
Probably more appropriate would be to use expr('CASE WHEN [premium]=1 THEN 0 ELSE 1 END')
or something similar like IF()
.
I wasn't looking at it as field = !<value>
though, but as field = !field
which would invert the value of a boolean or tinyint field.
It would be nice to be able to use it without needing to add additional parenthesis around it as in this workaround: ->set('premium', $q->expr('(!premium)'))
.
After further reading I discovered that !
is a valid mysql operator but is "nonstandard" and as of MySQL 8.0.17, it is deprecated.
Since my specific use case for the change isn't very solid I'll close the issue.
When using an Expression as the value in the set function, a space isn't added after the "=" sign. This causes an exception when trying to do something like this:
which renders as the following which isn't valid:
A workaround would be to rewrite this as: