type_bridge.expressions.base¶
base
¶
Base expression class for TypeQL query building.
Expression
¶
Bases: ABC
Base class for all query expressions.
Expressions represent query constraints that can be composed using boolean operators and converted to TypeQL patterns.
to_ast
abstractmethod
¶
Convert this expression to AST patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
The variable name to use in the pattern (e.g., "$e") |
required |
Returns:
| Type | Description |
|---|---|
list[Pattern]
|
List of AST patterns |
to_value_ast
¶
Convert this expression to an AST Value (if applicable).
Most expressions are patterns (filters) and cannot be converted to values. FunctionCall expressions and Literal wrappers are values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str | None
|
Optional variable name for aggregate expressions that need context. |
None
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If expression cannot be converted to a value. |
Source code in type_bridge/expressions/base.py
to_typeql
¶
Deprecated: Use to_ast() instead.
Source code in type_bridge/expressions/base.py
get_attribute_types
¶
Get all attribute types referenced by this expression.
Returns:
| Type | Description |
|---|---|
set[type[Attribute]]
|
Set of attribute types used in this expression |
Note
Default implementation returns attr_type if present. BooleanExpr overrides to recursively collect from operands.
Source code in type_bridge/expressions/base.py
and_
¶
Combine this expression with another using AND logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Expression
|
Another expression to AND with this one |
required |
Returns:
| Type | Description |
|---|---|
BooleanExpr
|
BooleanExpr representing the conjunction |
Source code in type_bridge/expressions/base.py
or_
¶
Combine this expression with another using OR logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Expression
|
Another expression to OR with this one |
required |
Returns:
| Type | Description |
|---|---|
BooleanExpr
|
BooleanExpr representing the disjunction |
Source code in type_bridge/expressions/base.py
not_
¶
Negate this expression using NOT logic.
Returns:
| Type | Description |
|---|---|
BooleanExpr
|
BooleanExpr representing the negation |