sql icon indicating copy to clipboard operation
sql copied to clipboard

Dynamic API?

Open jackfirth opened this issue 8 years ago • 1 comments

This package seems to provide two main pieces:

  1. A SQL-engine-agnostic AST and the ability to execute statements written in this AST
  2. A fancy and user-friendly macro-powered S-expression notation for constructing this AST

The second piece is nice when performing operations on a known table structure, but when trying to write libraries that abstract over bits of SQL the first piece is more important. It doesn't seem like dynamic constructors for the AST are stable or well documented. Based on the project TODOs, I'm guessing more support for the dynamic API is expected in the future. What do you imagine it looking like?

For reference, I'm trying to write a function that basically pairs an insert statement with a delete statement in a single value to automatically construct and destruct a row in a database for integration tests.

jackfirth avatar Jul 15 '17 05:07 jackfirth

Yes, the dynamic representation is private, and it will probably stay that way.

The priority for the dynamic API would be to enable abstraction where it currently isn't possible. Greg's request in #1, for dynamic selection of ORDER BY columns and directions, is a good example.

Probably the most power would come from adding functions for the various non-terminals to parse run-time s-expressions (or syntax objects) into ASTs. I think I'd rather do that than try to make a general make-select-stmt function.

rmculpepper avatar Jul 16 '17 18:07 rmculpepper