laravel/framework — pull request #5830 by bastiaan89 (2014-09-25 21:14:40+00:00)
Title: [4.2] Fix a bug with Expressions using false as value

As illustrated in the added unit test, the query builder (or rather, the underlying Grammar class) incorrectly converts ``where('attribute', new Expression(false))`` into ``'where attribute = '``, leading to SQL errors. The reason for this is actually PHP related, since ``false`` evaluates to an empty string, while ``true`` evaluates to ``'1'``. Either way, I added an exception for this in Expression's ``toString``, and changed the Grammar method to use the string value rather than the actual value.

An alternative solution would be to just return ``$expression`` and the string conversion would happen automatically as it is appended to the query string, but then I think you might as well just take out the entire ``getValue`` method.

I came across this issue while I was trying to add a global scope to a Model, where I realized I couldn't revert setting the query bindings in ``remove``. Then I found out that using Expression as a wrapper circumvents bindings by just injecting the actual value in the query rather than '?'. Would it be an idea to add a way to remove where clauses from a query, other than looping over all of them as is done in the SoftDeletingScope?