async_postgres/pg_sql_lexer

Search:
Group by:

SQL lexing shared by sqlParams, the sql macro and the compile-time $N check of queryDirect / execDirect, so all three agree on what is quoted or commented out.

Consts

sqlIdentContChars = {'$', '0'..'9', 'A'..'Z', '_', 'a'..'z', '\x80'..'\xFF'}

Templates

template sqlParseLoop(sql: string; output: var string; idx: var int;
                      normalBody: untyped)
Copies sql from idx to output while tracking quotes and comments. normalBody runs for each character in normal code that does not open a quote or comment, except a $ inside an identifier; the $ of $N reaches it. It advances idx and adds to output only what it keeps. Inside normalBody, c is sql[idx].