Skip to main content

Module neql

Module neql 

Source
Expand description

neQL — the whole language: NQL and PostgreSQL SQL.

Not a third dialect. neQL is the name for the pair, and this module is the one place that decides which half a statement is written in.

§Why the router lives in the engine

nesql-cli had this logic first, and it was correct there. Putting a second copy in the HTTP server would have been the same mistake this whole effort exists to undo: two implementations of one decision, drifting until POST /query and nesql query disagree about what a statement means — and disagreeing about the MEANING of a statement is worse than disagreeing about its result, because nothing looks broken.

So it moved down here, where both the daemon and the CLI can reach it, and the CLI re-exports it rather than keeping its own.

§Routing is structural, so nothing is guessed

NQL  begins with FROM
SQL  begins with SELECT INSERT UPDATE DELETE EXPLAIN WITH SHOW SET
                 VALUES TABLE BEGIN COMMIT ROLLBACK

PostgreSQL has no statement form that begins with FROM, so the leading keyword PARTITIONS the two vocabularies rather than hinting at them. That is what makes this a decision rather than a heuristic, and it is why a first word in neither is REFUSED naming both — never handed to whichever parser seems likelier, because “seems likelier” is the guess the rule forbids.

Enums§

Dialect
Which half of neQL a statement is written in.

Constants§

NQL_HEADS
Statement-initial keywords, per dialect. Disjoint by construction; the test the_two_vocabularies_do_not_overlap holds them that way.
SQL_HEADS

Functions§

route
Decide which half a statement is written in, or refuse.