THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
Translate Orionis query plans into engine-executable statements.
This is the only component, together with the connection and the
dialect helpers, aware of the underlying SQL toolkit. It converts
TableDefinition objects into engine table metadata (cached
per compiler) and query plans into executable statements.
| Static Method | _between |
Compile an inclusive range condition into a boolean expression. |
| Static Method | _combine |
Combine clauses using left-to-right boolean grouping. |
| Static Method | _raw |
Turn a raw SQL fragment into a bound engine element. |
| Static Method | supports |
Report whether an insert plan supports batch execution. |
| Method | __init__ |
Initialize the compiler with an optional table name prefix. |
| Method | _aggregate |
Compile an aggregate clause into a projection expression. |
| Method | _apply |
Extend a FROM clause with a single joined table. |
| Method | _apply |
Apply ordering, limit, and offset clauses to a statement. |
| Method | _apply |
Combine a compiled statement with the plan union branches. |
| Method | _bare |
Return the bare column name when a reference targets an identifier. |
| Method | _basic |
Compile a basic comparison clause into a boolean expression. |
| Method | _build |
Compile a select plan, correlating it with an enclosing query. |
| Method | _cache |
Build the internal table cache key, disambiguating by schema. |
| Method | _clause |
Compile a single where clause into a boolean expression. |
| Method | _clause |
Resolve the bound value of a clause, compiling nested subqueries. |
| Method | _collect |
Collect the column references of a clause list, recursing groups. |
| Method | _collect |
Collect every column reference touched anywhere in a select plan. |
| Method | _column |
Compile a comparison between two columns of the same query. |
| Method | _columnless |
Compile the clause kinds that carry no column reference. |
| Method | _ensure |
Lazily declare columns a plan references against a raw table. |
| Method | _ensure |
Register a stub table exposing the given referenced columns. |
| Method | _ensure |
Register a stub for a referenced table when it is unknown. |
| Method | _ensure |
Lazily declare raw columns referenced by a select plan's sources. |
| Method | _join |
Fold a join's ON conditions into a single boolean expression. |
| Method | _join |
Compile a single ON condition into a column-to-column comparison. |
| Method | _join |
Build the FROM source contributed by a single join expression. |
| Method | _physical |
Prepend the connection prefix to a logical table name. |
| Method | _projection |
Compile a single entry of a select projection. |
| Method | _resolve |
Resolve a column reference against the tables reachable in a plan. |
| Method | _resolve |
Build the main source, the resolvable source map, and the FROM. |
| Method | _select |
Build the base SELECT statement with its projection. |
| Method | _split |
Split a column reference into its table qualifier and column name. |
| Method | _sql |
Translate a column definition into an engine column. |
| Method | _sql |
Resolve and cache the engine table for a table definition. |
| Method | _sql |
Resolve the engine type backing a column definition. |
| Method | _table |
Build the composite, table-level constraints for a definition. |
| Method | _where |
Fold a sequence of where clauses into a boolean expression. |
| Method | compile |
Compile a table definition into a CREATE TABLE statement. |
| Method | compile |
Compile a delete plan into an executable DELETE statement. |
| Method | compile |
Compile a DROP TABLE statement for the given logical name. |
| Method | compile |
Compile an insert plan into an executable INSERT statement. |
| Method | compile |
Compile a select plan into an executable SELECT statement. |
| Method | compile |
Compile an update plan into an executable UPDATE statement. |
| Constant | _TYPE |
Undocumented |
| Class Variable | __slots__ |
Undocumented |
| Instance Variable | _definitions |
Undocumented |
| Instance Variable | _metadata |
Undocumented |
| Instance Variable | _prefix |
Undocumented |
| Instance Variable | _tables |
Undocumented |
ColumnElement[ Any], clause: WhereClause) -> ColumnElement[ bool]:
(source)
¶
Compile an inclusive range condition into a boolean expression.
| Parameters | |
column:ColumnElement | Column the range applies to. |
clause:WhereClause | Range condition carrying exactly two boundary values. |
| Returns | |
ColumnElement | Boolean expression for the range. |
| Raises | |
QueryException | If the clause does not carry exactly two boundaries. |
Callable[ ..., ColumnElement[ bool]], sources: SourceMap, default: SqlSource, clauses: Sequence[ WhereClause] | Sequence[ JoinCondition]) -> ColumnElement[ bool] | None:
(source)
¶
Combine clauses using left-to-right boolean grouping.
| Parameters | |
compileCallable | Function that translates one clause into a boolean expression. |
sources:SourceMap | Sources available while resolving clause references. |
default:SqlSource | Source used for unqualified column references. |
clauses:Sequence of WhereClause or JoinCondition | Clauses to combine in their declared order. |
| Returns | |
ColumnElement or None | Combined boolean expression, or None for an empty sequence. |
Turn a raw SQL fragment into a bound engine element.
Every value travels as a bound parameter, so the driver escapes it and the fragment cannot be used to smuggle literals. A raw fragment carrying an alias is compiled as a labeled column so it stays addressable when the query is used as a derived table.
| Parameters | |
raw:RawExpression | Fragment, its named bindings, and its optional alias. |
| Returns | |
ColumnElement | Textual element ready to be embedded in a statement. |
Report whether an insert plan supports batch execution.
| Parameters | |
plan:InsertPlan | Insert plan whose rows are checked for a shared parameter shape. |
| Returns | |
bool | Whether the rows can be sent as one batch without SQL expressions. |
SourceMap, default: SqlSource, aggregate: AggregateClause) -> ColumnElement[ Any]:
(source)
¶
Compile an aggregate clause into a projection expression.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
aggregate:AggregateClause | Aggregate projection description. |
| Returns | |
ColumnElement | Aggregate expression such as COUNT(*) or MAX(col). |
| Raises | |
QueryException | If a non-count aggregate targets "*". |
SqlSource, sources: SourceMap, join: JoinExpression) -> tuple[ SqlSource, str, SqlSource]:
(source)
¶
Extend a FROM clause with a single joined table.
| Parameters | |
fromSqlSource | FROM clause assembled so far. |
sources:SourceMap | Table sources already reachable by qualified references. |
join:JoinExpression | Join description to compile. |
| Returns | |
tuple of (SqlSource, str, SqlSource) | The extended FROM clause, the identifier the joined table is reachable by, and the joined source itself. |
| Raises | |
QueryException | If the join type is not supported, or its ON conditions cannot be resolved. |
SourceMap, default: SqlSource, statement: Select[ Any], plan: SelectPlan) -> Select[ Any]:
(source)
¶
Apply ordering, limit, and offset clauses to a statement.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
statement:Select | Statement being assembled. |
plan:SelectPlan | Engine-agnostic select description. |
| Returns | |
Select | Statement with ordering and pagination applied. |
Combine a compiled statement with the plan union branches.
Consecutive branches of the same kind form one flat compound. Mixed operators retain left-to-right semantics through derived tables, which also keeps the SQL valid on SQLite.
| Parameters | |
statement:Select | Statement compiled from the owning plan. |
plan:SelectPlan | Engine-agnostic select description carrying the unions. |
| Returns | |
CompoundSelect | Compound statement combining every branch. |
Return the bare column name when a reference targets an identifier.
| Parameters | |
name:str | Column reference, optionally qualified as "table.column". |
identifier:str | Alias or logical table name being checked against. |
| Returns | |
str or None | The bare column name when unqualified or matching identifier, otherwise None. |
ColumnElement[ Any], clause: WhereClause) -> ColumnElement[ bool]:
(source)
¶
Compile a basic comparison clause into a boolean expression.
NULL comparisons with equality operators are transparently promoted to IS NULL / IS NOT NULL.
| Parameters | |
column:ColumnElement | Column the comparison applies to. |
clause:WhereClause | Basic condition to compile. |
| Returns | |
ColumnElement | Boolean expression for the comparison. |
| Raises | |
QueryException | If the operator is not supported. |
Compile a select plan, correlating it with an enclosing query.
| Parameters | |
plan:SelectPlan | Engine-agnostic select description. |
outerSourceMap | Table sources of the enclosing query, so a subquery can reference outer columns and be correlated by the engine. |
| Returns | |
Select | Executable SELECT statement. |
| Raises | |
QueryException | If the plan references unknown columns or invalid clauses. |
SourceMap, default: SqlSource, clause: WhereClause) -> ColumnElement[ bool]:
(source)
¶
Compile a single where clause into a boolean expression.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
clause:WhereClause | Condition to compile. |
| Returns | |
ColumnElement | Boolean expression for the clause. |
| Raises | |
QueryException | If the clause uses an unsupported operator or shape. |
Resolve the bound value of a clause, compiling nested subqueries.
| Parameters | |
sources:SourceMap | Table sources of the enclosing query, used to correlate a subquery with the columns it references from outside. |
value:Any | Raw clause value taken from the plan. |
| Returns | |
Any | The value untouched, or the compiled subquery statement. |
Collect the column references of a clause list, recursing groups.
| Parameters | |
clauses:Sequence of WhereClause | Conditions to inspect. |
names:set of str | Accumulator receiving every referenced column name. |
| Returns | |
None | This method does not return a value. |
Collect every column reference touched anywhere in a select plan.
| Parameters | |
plan:SelectPlan | Engine-agnostic select description. |
| Returns | |
set of str | Every column name referenced by the plan, qualified or not. |
SourceMap, default: SqlSource, column: ColumnElement[ Any], clause: WhereClause) -> ColumnElement[ bool]:
(source)
¶
Compile a comparison between two columns of the same query.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
column:ColumnElement | Left-hand column of the comparison. |
clause:WhereClause | Condition carrying the right-hand column reference. |
| Returns | |
ColumnElement | Boolean expression comparing both columns. |
| Raises | |
QueryException | If the operator is not supported. |
SourceMap, default: SqlSource, clause: WhereClause) -> ColumnElement[ bool] | None:
(source)
¶
Compile the clause kinds that carry no column reference.
Covers nested groups, raw fragments, and correlated EXISTS subqueries; every other kind is left to the caller.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
clause:WhereClause | Condition to compile. |
| Returns | |
ColumnElement or None | Boolean expression, or None when the clause kind is column-based and must be handled by the caller. |
Lazily declare columns a plan references against a raw table.
A schemaless TableDefinition (no declared columns, used
by model-less builders such as DB.table("users")) has no
upfront column list for the compiler to validate against. Every
name the plan actually references for it is appended to its
engine table here, before any alias gets created, since
Table.alias().c memoizes on first access and would silently
miss columns appended afterwards.
| Parameters | |
table:TableDefinition | Table to inspect; a no-op unless it declares no columns. |
alias:str or None | Alias this table is referred to by inside the query. |
names:set of str | Every column reference collected from the owning plan. |
| Returns | |
None | This method does not return a value. |
Register a stub for a referenced table when it is unknown.
The stub only carries the referenced column so foreign key DDL can resolve its target; compiling the real model later replaces the stub through extend_existing.
| Parameters | |
reference:ForeignReference | Foreign reference to resolve. |
| Returns | |
None | This method does not return a value. |
Lazily declare raw columns referenced by a select plan's sources.
| Parameters | |
plan:SelectPlan | Engine-agnostic select description. |
| Returns | |
None | This method does not return a value. |
SourceMap, joined_name: str, joined_source: SqlSource, join: JoinExpression) -> ColumnElement[ bool]:
(source)
¶
Fold a join's ON conditions into a single boolean expression.
| Parameters | |
sources:SourceMap | Table sources reachable before this join is applied. |
joinedstr | Identifier the joined table is reachable by. |
joinedSqlSource | The joined table source itself. |
join:JoinExpression | Join description whose conditions are compiled. |
| Returns | |
ColumnElement | Combined boolean expression for the ON clause. |
| Raises | |
QueryException | If the join declares no ON conditions. |
SourceMap, default: SqlSource, condition: JoinCondition) -> ColumnElement[ bool]:
(source)
¶
Compile a single ON condition into a column-to-column comparison.
| Parameters | |
sources:SourceMap | Table sources reachable while resolving this condition. |
default:SqlSource | Source an unqualified column reference resolves against. |
condition:JoinCondition | ON condition to compile. |
| Returns | |
ColumnElement | Boolean expression comparing both column references. |
| Raises | |
QueryException | If the operator is not supported. |
Build the FROM source contributed by a single join expression.
| Parameters | |
join:JoinExpression | Join description to materialize. |
| Returns | |
tuple of (str, SqlSource) | The identifier the joined source is reachable by, and the source itself. |
| Raises | |
QueryException | If a subquery join declares no alias to be referenced by. |
SourceMap, default: SqlSource, entry: str | SubQueryColumn | RawExpression) -> ColumnElement[ Any]:
(source)
¶
Compile a single entry of a select projection.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
entry:str or SubQueryColumn or RawExpression | Projected column name, scalar subquery, or raw fragment. |
| Returns | |
ColumnElement | Engine element for the projection entry. |
SourceMap, default: SqlSource, name: str) -> ColumnElement[ Any]:
(source)
¶
Resolve a column reference against the tables reachable in a plan.
A qualified reference such as "posts.title" is looked up in sources by its table alias or name; an unqualified reference resolves against default (the plan's main table). This is the single place that understands multiple table origins, so joins, aliases, and future table expressions never need bespoke column lookup logic elsewhere in the compiler.
| Parameters | |
sources:SourceMap | Table sources reachable by alias or logical table name. |
default:SqlSource | Source an unqualified column reference resolves against. |
name:str | Column reference, optionally qualified as "table.column". |
| Returns | |
ColumnElement | Engine column element. |
| Raises | |
QueryException | If the qualifier is unknown, or the column is not declared on the resolved table. |
Build the main source, the resolvable source map, and the FROM.
The main table and every joined table are registered under the identifier queries use to qualify their columns: the alias when present, otherwise the logical table name. This is what lets _resolveColumn find "users.id" or "posts.title" regardless of how many tables participate in the query.
| Parameters | |
plan:SelectPlan | Engine-agnostic select description. |
| Returns | |
tuple of (SqlSource, SourceMap, SqlSource) | The main source (for unqualified projections), the source map keyed by alias or table name, and the compiled FROM clause (the main source joined with every configured join). |
SqlSource, sources: SourceMap, plan: SelectPlan) -> Select[ Any]:
(source)
¶
Build the base SELECT statement with its projection.
| Parameters | |
default:SqlSource | Source an unqualified column reference resolves against. |
sources:SourceMap | Table sources reachable by qualified column references. |
plan:SelectPlan | Engine-agnostic select description. |
| Returns | |
Select | Statement projecting the aggregate, explicit columns, or every column of the main table. |
ColumnDefinition, name: str | None = None) -> SqlColumn[ Any]:
(source)
¶
Translate a column definition into an engine column.
| Parameters | |
definition:ColumnDefinition | Orionis column definition. |
name:str or None, optional | Authoritative column name from the table definition mapping. |
| Returns | |
Column | Engine column with type and constraints applied. |
| Raises | |
QueryException | If the logical column type has no registered builder. |
Resolve and cache the engine table for a table definition.
| Parameters | |
definition:TableDefinition | Orionis table definition. |
| Returns | |
Table | Engine table metadata. |
Resolve the engine type backing a column definition.
| Parameters | |
definition:ColumnDefinition | Orionis column definition. |
| Returns | |
TypeEngine | Engine type, carrying a dialect variant when the declared type cannot auto-increment on every backend. |
| Raises | |
QueryException | If the logical column type has no registered builder. |
Build the composite, table-level constraints for a definition.
| Parameters | |
definition:TableDefinition | Orionis table definition. |
| Returns | |
list of Any | SQLAlchemy schema items to attach alongside the columns. |
SourceMap, default: SqlSource, clauses: Sequence[ WhereClause]) -> ColumnElement[ bool] | None:
(source)
¶
Fold a sequence of where clauses into a boolean expression.
Clauses are combined left to right honoring each clause boolean connector, mirroring the semantics of fluent query builders.
| Parameters | |
sources:SourceMap | Table sources reachable by qualified column references. |
default:SqlSource | Source an unqualified column reference resolves against. |
clauses:Sequence of WhereClause | Conditions to combine. |
| Returns | |
ColumnElement or None | Combined boolean expression, or None without clauses. |
TableDefinition, *, if_not_exists: bool = True) -> Executable:
(source)
¶
Compile a table definition into a CREATE TABLE statement.
| Parameters | |
definition:TableDefinition | Table definition to materialize. |
ifbool, optional | Whether to guard the statement with IF NOT EXISTS so that an already existing table is silently kept. |
| Returns | |
Executable | DDL statement creating the table. |
Compile a delete plan into an executable DELETE statement.
| Parameters | |
plan:DeletePlan | Engine-agnostic delete description. |
| Returns | |
Delete | Executable DELETE statement. |
str, schema: str | None = None, *, if_exists: bool = True) -> Executable:
(source)
¶
Compile a DROP TABLE statement for the given logical name.
| Parameters | |
name:str | Logical table name; the compiler prefix is applied. |
schema:str or None, optional | Database schema owning the table, or None for the default. |
ifbool, optional | Whether to guard the statement with IF EXISTS so that a missing table does not raise an error. |
| Returns | |
Executable | DDL statement dropping the table. |
Compile an insert plan into an executable INSERT statement.
| Parameters | |
plan:InsertPlan | Engine-agnostic insert description. |
parameterized:bool, optional | Leave row values for executemany parameters supplied at execution. |
| Returns | |
Insert | Executable INSERT statement. |
| Raises | |
QueryException | If the plan carries no rows to insert. |
Compile a select plan into an executable SELECT statement.
| Parameters | |
plan:SelectPlan | Engine-agnostic select description. |
| Returns | |
Select or CompoundSelect | Executable SELECT statement; a compound statement when the plan carries unions. |
| Raises | |
QueryException | If the plan references unknown columns or invalid clauses. |
Compile an update plan into an executable UPDATE statement.
| Parameters | |
plan:UpdatePlan | Engine-agnostic update description. |
| Returns | |
Update | Executable UPDATE statement. |
| Raises | |
QueryException | If the plan carries no values to assign. |
ClassVar[ dict[ ColumnType, Callable[ [ ColumnDefinition], TypeEngine[ Any]]]] =
(source)
¶
Undocumented
| Value |
|