OpenGen / GenSQL.query

42 stars 5 forks source link

Change BNF and code to use single-quoted strings instead of double #80

Closed KingMob closed 8 months ago

KingMob commented 9 months ago

Update the BNF and supporting code to use single quotes instead of double quotes for strings, bringing IQL more in line with SQL.

KingMob commented 8 months ago

The original code included the double quotes inside the string representation of a :string node, like \"somevar\"

Roughly speaking, I saw two strategies to consider when switching to single quotes. I went with (1) below.

  1. Remove the quotes from inside the string value in the parse tree, and leverage the node's tag (:string) when we need to generate readable Clojure.
  2. Transform the :string node values immediately after parsing so that they are wrapped in double quotes internally, like they were before.

(1) involves some small changes, mostly wrapping with double quotes in literal/read, and making sure that scalar/plan doesn't invoke edn/read-string directly any more, but calls literal/read.

(2) would involve the fewest changes, but I was concerned it would be surprising, hard to unparse, or lead to confusion with double-quoted delimited identifiers. Generally, it's redundant info that would no longer match what was parsed, which just feels like a recipe for trouble somewhere down the line.