Get all predicates as string with the correct cast type and the correct prefix.
Parameters: |
result (List[str] ) – List contains the request.
fquery (Callable[[py_linq_sql.utils.classes.magicdotpath.BaseMagicDotPath], Union[py_linq_sql.utils.classes.magicdotpath.BaseMagicDotPath, Tuple[py_linq_sql.utils.classes.magicdotpath.BaseMagicDotPath], Dict[str, py_linq_sql.utils.classes.magicdotpath.BaseMagicDotPath]]] ) – Lambda function to get paths.
sqle (SQLEnumerableData ) – SQLEnumerableData with connection, flags, list of commands and a table.
|
Exceptions: |
TypeError – If the type of mdp_w_path isn't BaseMagicDotPath
or tuple of BaseMagicDotPath,
or indirect raise by get_one_predicate_as_str .
psycopg.Error – Indirect raise by get_one_predicate_as_str .
TableError – Indirect raise by get_one_predicate_as_str .
TypeOperatorError – Indirect raise by BaseMagicDotPath._get_number_operator
or BaseMagicDotPath._get_generic_operator .
|
Source code in py_linq_sql/utils/functions/predicate_functions.py
def get_predicates_as_str(
result: List[str],
fquery: LambdaMagicDotPath,
sqle: SQLEnumerableData,
) -> None:
"""
Get all predicates as string with the correct cast type and the correct prefix.
Args:
result: List contains the request.
fquery: Lambda function to get paths.
sqle: SQLEnumerableData with connection, flags, list of commands and a table.
Returns:
Predicates as a string with the correct cast type and prefix.
Raises:
TypeError: If the type of mdp_w_path isn't BaseMagicDotPath
or tuple of BaseMagicDotPath,
or indirect raise by `get_one_predicate_as_str`.
psycopg.Error: Indirect raise by `get_one_predicate_as_str`.
TableError: Indirect raise by `get_one_predicate_as_str`.
TypeOperatorError: Indirect raise by `BaseMagicDotPath._get_number_operator`
or `BaseMagicDotPath._get_generic_operator`.
"""
mdp_w_path = fquery(MagicDotPath(sqle.connection))
match mdp_w_path:
case BaseMagicDotPath():
result.append(get_one_predicate_as_str(sqle, mdp_w_path))
case tuple():
result.append(
" AND ".join(
[get_one_predicate_as_str(sqle, mdp) for mdp in mdp_w_path],
),
)
case _:
raise TypeError(
"Only BaseMagicDotPath or tuple of BaseMagicDotPath are accepted.",
)