SQL Commonο
- ANY_JOIN = *.*=*.*ο
A convenience object that represents any valid join condition. Only use it for a validator that represents full admin access to your database.
- class FqColumn(*, table: str, column: str)ο
This represents a fully-qualified column name.
We require that LLM-produced queries from SQL Bifrosts use fully-qualified columns in their clauses, because if they didnβt, we would need to infer which table owned the column, which requires runtime schema analysis. We could do that, but maybe in the future. Itβs much more straightforward to instruct that the LLM give us fully-qualified names.
- classmethod from_string(fq_column_name: str) FqColumn ο
Parses a fully-qualified column name from a string, using the expected format of
table.column
- Parameters:
fq_column_name (str) β The fully-qualified column name.
- Raises:
UnqualifiedColumn β If the string does not contain a period.
- Return type:
- class JoinCondition(first: str, second: str, *, identity: str | None = None)ο
This represents an equi-join between two tables, on two columns. The order of the fully-qualified columns does not matter; matching will work correctly in the code.
- Parameters:
first (str) β The first fully-qualified column.
second (str) β The second fully-qualified column.
identity (str | None) β If the columns specified in this join condition can also be used as a
requester identity
for the query, then this should be set to the name of the placeholder where the identity will be populated at runtime.
- class ParameterizedConstraint(*, column: str, placeholder: str)ο
This represents a constraint that must be applied to the query.
In the query, this comes in the form of
table.column=:placeholder
. Enforced by the grammar, the comparison is always equality, the left hand side is always a fully-qualified column, and the right hand side is always a placeholder. These requirements ensure that the query is always constrained by a value that the developer specifies at query execution time.