qsql (equery v0.22.0)

View Source

SQL statement compilation.

Turns a q:query/0 into a qast:ast_node/0 of a specific top-level statement. Pair with qast:to_sql/1 to get {Sql, Args} ready for parameterized execution.

Summary

Functions

Compile a query into a DELETE statement AST. Includes RETURNING.

Compile a query into an INSERT statement AST.

Compile a query into a SELECT statement AST.

Compile a query into an UPDATE statement AST. Includes RETURNING.

Functions

delete/1

-spec delete(q:query()) -> qast:ast_node().

Compile a query into a DELETE statement AST. Includes RETURNING.

insert/1

-spec insert(q:query()) -> qast:ast_node().

Compile a query into an INSERT statement AST.

If set is a query(), emits INSERT INTO t (...) SELECT .... If set is a map, emits INSERT INTO t (...) VALUES (...). Always includes RETURNING (controlled via q:select/1,2).

select/1

-spec select(q:query()) -> qast:ast_node().

Compile a query into a SELECT statement AST.

update/1

-spec update(q:query()) -> qast:ast_node().

Compile a query into an UPDATE statement AST. Includes RETURNING.