Skip to main content

Module parse

Module parse 

Source
Expand description

Helpers for recovering structured pieces (column lists, WHERE clauses, placeholder counts) from a SQL string that was built by one of the operations/*::build_sql paths. Driver engines need these when the dialect can’t emit RETURNING and the driver has to run a follow-up SELECT keyed on the same WHERE/PK values the original statement used.

Scoped-lexer caveats: these helpers are case-insensitive token scans, not a real SQL parser. They work correctly on the generated output of prax-query’s own operations/*::build_sql — they do not try to handle arbitrary user SQL with string literals containing ? / where / etc. Callers that accept raw user SQL must either reject malformed input up front or avoid these helpers.

Functions§

count_set_placeholders
Count the ? placeholders inside an UPDATE statement’s SET clause (between SET and WHERE). Used to split bound params between SET values and WHERE values for CQL drivers that need to issue a follow-up SELECT. Returns None when the SET window can’t be located.
extract_insert_columns
Extract the comma-separated column list from an INSERT INTO tbl (col1, col2, ...) VALUES … statement. Returns None if the statement doesn’t have a column list.
extract_where_body
Extract the WHERE clause body (everything after the first case- insensitive WHERE token) from an UPDATE / DELETE / SELECT. Returns None if there is no WHERE clause.