SQLite Forum

Inconsistent output possibly due to affinity issue
Login
Constant propagation is taking place in the where clause expression, but not in the select expression.

That is, in the first case

WHERE v1 = 10 and v1 like 10

devolves to

WHERE v1 = 10 and 10 like 10


However, in the select clause the constant 10 is not propagated and the expression is evaluated as written and the stringification of v1 (when a real) is not LIKE the stringification of the integer 10 (an integer).

So either  
 (a) constant propagation should also occur in the SELECT expressions or  
 (b) the result is correct.

While this may appear inconsistent, I cannot state whether it is or not.  It is a consequence of the "query optimization" not optimizing the select expression.