mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-26 04:24:21 +01:00
This PR is a Drop-In replacement to the Predicate defined in the Simulator. Predicate is basically the same as our ast::Expr, but it supports a small number of the SQL expression syntax. By creating a NewType that wraps ast::Expr we can tap into our already mostly correctly defined parser structs. This change will enable us to easily add generation for more types of sql queries. I also added an ArbitraryFrom impl for ast::Expr that can be used in a freestyle way (for now) for differential testing. This PR also aims to implement Unary Operator logic similar to the Binary Operator logic we have for predicate. After this change we may need to adjust the Logic for how some assertions are triggered. <s>Sometimes the `Select-Select-Optimizer` property thinks that these two queries should return the same thing: ```sql SELECT (twinkling_winstanley.sensible_federations > x'66616e7461737469625e0f37879823db' AND twinkling_winstanley.sincere_niemeyer < -7428368947470022783) FROM twinkling_winstanley WHERE 1; SELECT * FROM twinkling_winstanley WHERE twinkling_winstanley.sensible_federations > x'66616e7461737469625e0f37879823db' AND twinkling_winstanley.sincere_niemeyer < -7428368947470022783; ``` However after running the shrunk plan manually, the simulator was incorrect in asserting that. Maybe this a bug a in the generation of such a query? Not sure yet. </s> <b>EDIT: The simulator was correctly catching a bug and I thought I was the problem. The bug was in `exec_if` and I fixed it in this PR.</b> I still need to expand the Unary Operator generation to other types of predicates. For now, I just implemented it for `SimplePredicate` as I'm trying to avoid to bloat even more this PR. <b>EDIT: I decided to just have one PR open for all the changes I'm making to make my life a bit easier and to avoid merge conflicts with my own branches that I keep spawning for new code.</b> PS: This should only be considered for merging after https://github.com/tursodatabase/limbo/pull/1619 is merged. Then, I will remove the draft status from this PR. Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #1674