mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-23 01:44:33 +01:00
This PR implements the `ToSqlString` trait to most of the `ast` structs and to the `SelectPlan`, `UpdatePlan`, `DeletePlan`, `CompoundSelectPlan`. Inside the files in the `to_sql_string` folder, I annotated many `TODOs` with things that seem to diverge from SQLite syntax. The most egregious by far was that Create Trigger statements do not use the standard `delete`, `select`, `update`, and `insert` statements. The parser uses different structs for those statements only in Create Trigger. E.g `ast::TriggerCmdUpdate` instead of `ast::Update` and so on. Also, as this iteration of reverse parsing is not particularly efficient in the number of string allocations it does. I tested different methods of achieving this by using `format!`, pushing directly to a `String`, or just pushing to `Vec<String>` and joining all the string with a space separator. I focused mainly on trying to get the syntax to print correctly without major hurdles in understanding the code. Lastly, I intend in the future to use this code in the simulator to expand the its available syntax. Closes #1619