From: John Cowan <xxxxxx@ccil.org>
Date: Saturday, October 19, 2019 7:36 PM
I got an idea for an agnostic representation of SQL statements as S-expressions that doesn't depend on the particular syntax of the SQL dialect it is going to be translated into. All it needs to know is the lexical syntax of SQL identifiers and strings, and the fact that sequences may be comma-separated with or without parentheses and may be space-separated, with a convention for representing the three types using lists (comma-separated with parens), vectors (space-separated), and vectors whose sole element is a list (comma-separated without parens).
Looks interesting. One thing I'd like that isn't allowed would be the two examples below being equivalent:
(create-table-if-not-exists items
(#(itemid varchar-not-null))
and
(CREATE-TABLE-IF-NOT-EXISTS items
(#(itemid VARCHAR-NOT-NULL))
Since I normally like to uppercase SQL keywords just like the target statement you provided:
CREATE TABLE IF NOT EXISTS items(
itemid VARCHAR NOT NULL,
Is the rule that implicitly forbids that:
A symbol or symbol part that contains only lower-case or caseless letters (not just ASCII), digits, and underscore is output as is. If it contains any other characters, it is output in double quotes. If it contains a double quote, that character is doubled.
Sufficient to create all double quoted passages? And/or would it double quote something you don't want?
select "count of" from
(select account_id,count(*) "count of" from orders group by 1)sub where "count of" >20;
- Harold