exosql v0.2.87 ExoSQL.Parser View Source

Parsed an SQL statement into a ExoSQL.Query.

The Query then needs to be planned and executed.

It also resolves partial column and table names using data from the context and its schema functions.

Uses leex and yecc to perform a first phase parsing, and then convert an dprocess the structure using more context knowledge to return a proper Query struct.

Link to this section Summary

Functions

Parses an SQL statement and returns the parsed ExoSQL struct

Calculates the list of all FQcolumns

Resolves all known tables at this context. This helps to fully qualify tables

From the list of tables, and context, and an unknown column, return the FQN of the column

Given a table-like tuple, returns the real table names

Link to this section Functions

Link to this function get_table_columns(arg, all_columns) View Source

Parses an SQL statement and returns the parsed ExoSQL struct.

Link to this function resolve_all_columns(tables, context) View Source

Calculates the list of all FQcolumns.

This simplifies later the gathering of which table has which column and so on, specially when aliases are taken into account

Link to this function resolve_all_tables(context) View Source

Resolves all known tables at this context. This helps to fully qualify tables.

TODO Could be more efficient accessing as little as possible the schemas, but maybe not possible.

Link to this function resolve_column(column, all_columns, context) View Source

From the list of tables, and context, and an unknown column, return the FQN of the column.

Link to this function resolve_columns(q, context) View Source
Link to this function resolve_table(orig, all_tables, context) View Source

Given a table-like tuple, returns the real table names

The table-like can be a function, a lateral join, or a simple table. It resolves unknown parts, as for example {:table, {nil, “table”}}, will fill which db.

It returns the same form, but with more data, and calling again will result in the same result.