Closed davidAtInleague closed 1 year ago
@elpete We would be happy to have some direction on this as we have one other bug we'd like to submit a PR for, but I know you're working on QB 9 and if you're working on solving any of these differently we won't invest the effort on our side until you're ready for us. We're trying to get Quick 5 merged into our daily workflow ASAP!
Just making sure I understand the problem we're solving.
Without this change, do all the where clauses get combined together? Something like this?
SELECT *
FROM `users`
WHERE (
`users`.`first_name` = ?
AND `users`.`last_name` = ?
OR `users`.`first_name` = ?
AND `users`.`last_name` = ?
)
Hi, yes, we see the following emitted sql, for the same scope invocation across different versions, where 4.1.3 is correct:
v4.1.3
SELECT [RMME_C].[id_c] FROM [RMME_C] WHERE (([id] = ? AND [id] != ?) OR ([id] = ? AND [id] != ?))
v5.2.0
SELECT [RMME_C].[id_c] FROM [RMME_C] WHERE [id] = ? AND [id] != ? AND [id] = ? AND [id] != ?
Thank you for the code, and thank you for your patience.
callback(query)
seems like a purely isolated functional thing, but it makes assumptions about its environment, and the existing qb object in the existing environment has where's piled up in it which we don't want to flatten with the nested result. It looks like updating the context (read: the available QB object) during descent into the callback, and then restoring the original context afterwards, keeps the two contexts from flattening their wheres together.Fixes https://github.com/coldbox-modules/quick/issues/212