High level utilities which build upon other modules here.
Class |
|
Clones and modifies clauses based on column correspondence. |
Class |
|
Extends ClauseAdapter with extra utility functions. |
Function | adapt |
given criterion containing bind params, convert selected elements to IS NULL. |
Function | bind |
Return an ordered list of "bound" values in the given clause. |
Function | clause |
Given a target clause and a second to search within, return True if the target is plainly present in the search without any subqueries or aliases involved. |
Function | criterion |
traverse an expression and locate binary criterion pairs. |
Function | expand |
Given the columns clause and ORDER BY of a selectable, return a list of column expressions that can be added to the collist corresponding to the ORDER BY, without repeating those already in the collist. |
Function | extract |
Undocumented |
Function | find |
Given a list of FROM clauses and a selectable, return the first index and element from the list of clauses which can be joined against the selectable. returns None, None if no match is found. |
Function | find |
Given a list of FROM clauses and a selectable, return the indexes from the list of clauses which is derived from the selectable. |
Function | find |
Given a list of FROM clauses, a selectable, and optional ON clause, return a list of integer indexes from the clauses list indicating the clauses that can be joined from. |
Function | find |
locate Table objects within the given expression. |
Function | join |
Create a join condition between two tables or selectables. |
Function | reduce |
given a list of columns, return a 'reduced' set based on natural equivalents. |
Function | selectables |
Return True if left/right have some overlapping selectable |
Function | splice |
Undocumented |
Function | surface |
Undocumented |
Function | surface |
Undocumented |
Function | tables |
Undocumented |
Function | unwrap |
Undocumented |
Function | unwrap |
Break up an 'order by' expression into individual column-expressions, without DESC/ASC/NULLS FIRST/NULLS LAST |
Function | visit |
Produce a traversal of the given expression, delivering column comparisons to the given function. |
Class | _ |
Undocumented |
Class | _long |
Undocumented |
Class | _repr |
Undocumented |
Class | _repr |
Provide a string view of bound parameters. |
Class | _repr |
Provide a string view of a row. |
Function | _make |
Compute LIMIT/OFFSET in terms of slice start/end |
Function | _offset |
Convert the given value to an "offset or limit" clause. |
Function | _offset |
Return the offset or limit clause as a simple integer if possible, else return the clause. |
Function | _quote |
Undocumented |
Function | _repr |
Undocumented |
Type Variable | _CE |
Undocumented |
Return an ordered list of "bound" values in the given clause. E.g.:: >>> expr = and_( ... table.c.foo==5, table.c.foo==7 ... ) >>> bind_values(expr) [5, 7]
Given a target clause and a second to search within, return True if the target is plainly present in the search without any subqueries or aliases involved. Basically descends through Joins.
traverse an expression and locate binary criterion pairs.
Given the columns clause and ORDER BY of a selectable, return a list of column expressions that can be added to the collist corresponding to the ORDER BY, without repeating those already in the collist.
Given a list of FROM clauses and a selectable, return the first index and element from the list of clauses which can be joined against the selectable. returns None, None if no match is found. e.g.:: clause1 = table1.join(table2) clause2 = table4.join(table5) join_to = table2.join(table3) find_join_source([clause1, clause2], join_to) == clause1
Sequence[ FromClause]
, join_from: FromClause
) -> List[ int]
:
(source)
¶
Given a list of FROM clauses and a selectable, return the indexes from the list of clauses which is derived from the selectable.
Sequence[ FromClause]
, join_to: _JoinTargetElement
, onclause: Optional[ ColumnElement[ Any]]
) -> List[ int]
:
(source)
¶
Given a list of FROM clauses, a selectable, and optional ON clause, return a list of integer indexes from the clauses list indicating the clauses that can be joined from. The presence of an "onclause" indicates that at least one clause can definitely be joined from; if the list of clauses is of length one and the onclause is given, returns that index. If the list of clauses is more than length one, and the onclause is given, attempts to locate which clauses contain the same columns.
ClauseElement
, *, check_columns: bool
= False, include_aliases: bool
= False, include_joins: bool
= False, include_selects: bool
= False, include_crud: bool
= False) -> List[ TableClause]
:
(source)
¶
locate Table objects within the given expression.
FromClause
, b: FromClause
, a_subset: Optional[ FromClause]
= None, consider_as_foreign_keys: Optional[ AbstractSet[ ColumnClause[ Any]]]
= None) -> ColumnElement[ bool]
:
(source)
¶
Create a join condition between two tables or selectables. e.g.:: join_condition(tablea, tableb) would produce an expression along the lines of:: tablea.c.id==tableb.c.tablea_id The join is determined based on the foreign key relationships between the two selectables. If there are multiple ways to join, or no way to join, an error is raised. :param a_subset: An optional expression that is a sub-component of ``a``. An attempt will be made to join to just this sub-component first before looking at the full ``a`` construct, and if found will be successful even if there are other ways to join to ``a``. This allows the "right side" of a join to be passed thereby providing a "natural join".
Iterable[ ColumnElement[ Any]]
, *clauses: Optional[ ClauseElement]
, **kw: bool
) -> Sequence[ ColumnElement[ Any]]
:_SelectIterable
, *clauses: Optional[ ClauseElement]
, **kw: bool
) -> Sequence[ Union[ ColumnElement[ Any], TextClause]]
:given a list of columns, return a 'reduced' set based on natural equivalents. the set is reduced to the smallest list of columns which have no natural equivalent present in the list. A "natural equivalent" means that two columns will ultimately represent the same value because they are related by a foreign key. \*clauses is an optional list of join clauses which will be traversed to further identify columns that are "equivalent". \**kw may specify 'ignore_nonexistent_tables' to ignore foreign keys whose tables are not yet configured, or columns that aren't yet present. This function is primarily used to determine the most minimal "primary key" from a selectable, by reducing the set of primary key columns present in the selectable to just those that are not repeated.
Optional[ FromClause]
, right: Optional[ FromClause]
, stop_on: Optional[ FromClause]
= None) -> Optional[ FromClause]
:
(source)
¶
Undocumented
Break up an 'order by' expression into individual column-expressions, without DESC/ASC/NULLS FIRST/NULLS LAST
Callable[ [ BinaryExpression[ Any], ColumnElement[ Any], ColumnElement[ Any]], None]
, expr: ColumnElement[ Any]
):
(source)
¶
Produce a traversal of the given expression, delivering column comparisons to the given function. The function is of the form:: def my_fn(binary, left, right) For each binary expression located which has a comparison operator, the product of "left" and "right" will be delivered to that function, in terms of that binary. Hence an expression like:: and_( (a + b) == q + func.sum(e + f), j == r ) would have the traversal:: a <eq> q a <eq> e a <eq> f b <eq> q b <eq> e b <eq> f j <eq> r That is, every combination of "left" and "right" that doesn't further contain a binary comparison is passed as pairs.
_LimitOffsetType
, offset_clause: _LimitOffsetType
, start: int
, stop: int
) -> Tuple[ Optional[ ColumnElement[ int]], Optional[ ColumnElement[ int]]]
:
(source)
¶
Compute LIMIT/OFFSET in terms of slice start/end
_LimitOffsetType
, name: Optional[ str]
= None, type_: Optional[ _TypeEngineArgument[ int]]
= None) -> ColumnElement[ int]
:
(source)
¶
Convert the given value to an "offset or limit" clause. This handles incoming integers and converts to an expression; if an expression is already given, it is passed through.
_LimitOffsetType
) -> _LimitOffsetType
:
(source)
¶
Return the offset or limit clause as a simple integer if possible, else return the clause.