type_bridge.expressions.boolean¶
boolean
¶
Boolean expressions for logical combinations.
BooleanExpr
¶
Bases: Expression
Boolean expression for combining other expressions with AND, OR, NOT.
Represents logical combinations of query constraints.
Create a boolean expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
Literal['and', 'or', 'not']
|
Boolean operation type |
required |
operands
|
list[Expression]
|
List of expressions to combine |
required |
Source code in type_bridge/expressions/boolean.py
get_attribute_types
¶
Get all attribute types referenced by this boolean expression.
Recursively collects attribute types from all operands.
Returns:
| Type | Description |
|---|---|
set[type[Attribute]]
|
Set of attribute types used in this expression and its operands |
Source code in type_bridge/expressions/boolean.py
to_ast
¶
Generate AST patterns for this boolean expression.
Source code in type_bridge/expressions/boolean.py
and_
¶
Combine with another expression using AND, flattening if possible.
If this is already an AND expression, adds the new operand to create a flat structure instead of a nested binary tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Expression
|
Another expression to AND with this one |
required |
Returns:
| Type | Description |
|---|---|
BooleanExpr
|
BooleanExpr with flattened operands |
Source code in type_bridge/expressions/boolean.py
or_
¶
Combine with another expression using OR, flattening if possible.
If this is already an OR expression, adds the new operand to create a flat structure instead of a nested binary tree. This is critical for avoiding TypeDB query planner stack overflow with many values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Expression
|
Another expression to OR with this one |
required |
Returns:
| Type | Description |
|---|---|
BooleanExpr
|
BooleanExpr with flattened operands |