acapy_agent.database_manager.wql_nosql package

Subpackages

Submodules

acapy_agent.database_manager.wql_nosql.query module

Askar WQL (Wallet Query Language) parsing and optimization.

class acapy_agent.database_manager.wql_nosql.query.AndQuery(subqueries: List[Query])[source]

Bases: Query

Logical AND of multiple clauses.

map(key_func, value_func)[source]

Transform keys and values in the AND query.

optimise() Query | None[source]

Optimize the AND query by simplifying its structure.

to_dict()[source]

Convert the AND query to a JSON-compatible dictionary.

class acapy_agent.database_manager.wql_nosql.query.EqQuery(key: str, value: str)[source]

Bases: Query

Equality comparison for a field value.

map(key_func, value_func)[source]

Transform key and value in the equality query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.ExistQuery(keys: List[str])[source]

Bases: Query

Match any non-null field value of the given field names.

map(key_func, value_func)[source]

Transform keys and values in the exist query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.GtQuery(key: str, value: str)[source]

Bases: Query

Greater-than comparison for a field value.

map(key_func, value_func)[source]

Transform keys and values in the gt query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.GteQuery(key: str, value: str)[source]

Bases: Query

Greater-than-or-equal comparison for a field value.

map(key_func, value_func)[source]

Transform keys and values in the gte query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.InQuery(key: str, values: List[str])[source]

Bases: Query

Match one of multiple field values in a set.

map(key_func, value_func)[source]

Transform keys and values in the in query.

optimise()[source]

Optimize by converting single value to EqQuery.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.LikeQuery(key: str, value: str)[source]

Bases: Query

SQL ‘LIKE’-compatible string comparison for a field value.

map(key_func, value_func)[source]

Transform keys and values in the like query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.LtQuery(key: str, value: str)[source]

Bases: Query

Less-than comparison for a field value.

map(key_func, value_func)[source]

Transform keys and values in the lt query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.LteQuery(key: str, value: str)[source]

Bases: Query

Less-than-or-equal comparison for a field value.

map(key_func, value_func)[source]

Transform keys and values in the lte query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.NeqQuery(key: str, value: str)[source]

Bases: Query

Inequality comparison for a field value.

map(key_func, value_func)[source]

Transform key and value in the inequality query.

optimise()[source]

Return self as no optimization is needed.

to_dict()[source]

Convert to dictionary representation.

class acapy_agent.database_manager.wql_nosql.query.NotQuery(subquery: Query)[source]

Bases: Query

Negation of a clause.

map(key_func, value_func)[source]

Transform keys and values in the NOT query.

optimise() Query | None[source]

Optimize the NOT query by simplifying its structure.

to_dict()[source]

Convert the NOT query to a JSON-compatible dictionary.

class acapy_agent.database_manager.wql_nosql.query.OrQuery(subqueries: List[Query])[source]

Bases: Query

Logical OR of multiple clauses.

map(key_func, value_func)[source]

Transform keys and values in the OR query.

optimise() Query | None[source]

Optimize the OR query by simplifying its structure.

to_dict()[source]

Convert the OR query to a JSON-compatible dictionary.

class acapy_agent.database_manager.wql_nosql.query.Query[source]

Bases: object

Base class for all query types.

map(key_func: Callable[[str], str], value_func: Callable[[str, str], str]) Query[source]

Transform keys and values in the query.

map_names(key_func: Callable[[str], str]) Query[source]

Transform only the keys in the query.

map_values(value_func: Callable[[str, str], str]) Query[source]

Transform only the values in the query.

optimise() Query | None[source]

Optimize the query by simplifying its structure.

to_dict() dict[source]

Convert the query to a JSON-compatible dictionary.

acapy_agent.database_manager.wql_nosql.query.parse_operator(key: str, value: dict | list | str | None) Query | None[source]

Parse an operator from a key-value pair.

acapy_agent.database_manager.wql_nosql.query.parse_query(query_dict: dict) Query[source]

Parse a dictionary into a Query object.

acapy_agent.database_manager.wql_nosql.query.parse_single_operator(op_name: str, key: str, value: dict | list | str | None) Query[source]

Parse a single operator from a key-value pair.

acapy_agent.database_manager.wql_nosql.query.query_from_json(json_value: dict | list | str | None) Query[source]

Parse a JSON value (dict or list) into a Query object.

acapy_agent.database_manager.wql_nosql.query.query_from_str(json_str: str) Query[source]

Parse a JSON string into a Query object.

acapy_agent.database_manager.wql_nosql.query.query_to_str(query: Query) str[source]

Convert a Query object to a JSON string.

acapy_agent.database_manager.wql_nosql.tags module

Module docstring.

class acapy_agent.database_manager.wql_nosql.tags.CompareOp(*values)[source]

Bases: Enum

Class description.

Eq = '='
Gt = '>'
Gte = '>='
Like = 'LIKE'
Lt = '<'
Lte = '<='
Neq = '!='
as_sql_str()[source]

Perform the action.

as_sql_str_for_prefix()[source]

Perform the action.

class acapy_agent.database_manager.wql_nosql.tags.ConjunctionOp(*values)[source]

Bases: Enum

Class description.

And = ' AND '
Or = ' OR '
as_sql_str()[source]

Perform the action.

negate()[source]

Perform the action.

class acapy_agent.database_manager.wql_nosql.tags.TagName(value)[source]

Bases: object

Represents a tag name for WQL queries.

to_string()[source]

Perform the action.

class acapy_agent.database_manager.wql_nosql.tags.TagQuery(variant: str, data: TagQuery | List[TagQuery] | TagName | str | List[str])[source]

Bases: object

Class description.

static and_(subqueries: List[TagQuery])[source]

Perform the action.

static eq(name: TagName, value: str)[source]

Perform the action.

static exist(names: List[TagName])[source]

Perform the action.

static gt(name: TagName, value: str)[source]

Perform the action.

static gte(name: TagName, value: str)[source]

Perform the action.

static in_(name: TagName, values: List[str])[source]

Perform the action.

static like(name: TagName, value: str)[source]

Perform the action.

static lt(name: TagName, value: str)[source]

Perform the action.

static lte(name: TagName, value: str)[source]

Perform the action.

static neq(name: TagName, value: str)[source]

Perform the action.

static not_(subquery: TagQuery)[source]

Perform the action.

static or_(subqueries: List[TagQuery])[source]

Perform the action.

to_wql_dict()[source]

Convert the TagQuery to a WQL-compatible dictionary.

to_wql_str()[source]

Convert the TagQuery to a WQL JSON string.

class acapy_agent.database_manager.wql_nosql.tags.TagQueryEncoder[source]

Bases: ABC

Class description.

encode_conj(op: ConjunctionOp, subqueries: List[TagQuery], negate: bool)[source]

Perform the action.

abstractmethod encode_conj_clause(op: ConjunctionOp, clauses: List[str]) str[source]

Perform the action.

encode_exist(names: List[TagName], negate: bool)[source]

Perform the action.

abstractmethod encode_exist_clause(enc_name: bytes, negate: bool) str[source]

Perform the action.

encode_in(name: TagName, values: List[str], negate: bool)[source]

Perform the action.

abstractmethod encode_in_clause(enc_name: bytes, enc_values: List[bytes], negate: bool) str[source]

Perform the action.

abstractmethod encode_name(name: TagName) bytes[source]

Perform the action.

encode_op(op: CompareOp, name: TagName, value: str, negate: bool)[source]

Perform the action.

abstractmethod encode_op_clause(op: CompareOp, enc_name: bytes, enc_value: bytes, negate: bool) str[source]

Perform the action.

encode_query(query: TagQuery, negate: bool = False) str[source]

Encode a TagQuery using mapping-based dispatch to reduce branching.

abstractmethod encode_value(value: str) bytes[source]

Perform the action.

acapy_agent.database_manager.wql_nosql.tags.query_to_tagquery(q)[source]

Convert a Query object from query.py to a TagQuery object from tags.py.

Strips ‘~’ from keys as it is no longer used to determine tag type. NOTE: this is for backward compatibility as the caller will continue to provide the ~ character for plaintext.

acapy_agent.database_manager.wql_nosql.test_string_to_tagquery module

Tests for string to TagQuery conversion.

class acapy_agent.database_manager.wql_nosql.test_string_to_tagquery.TestQuery(methodName='runTest')[source]

Bases: TestCase

Test cases for query parsing, serialization, and optimization.

test_and_exist()[source]

Test parsing an AND query with EXIST subqueries.

test_and_or_not_complex_case_parse()[source]

Test parsing a complex query with AND, OR, and NOT subqueries.

test_and_or_not_complex_case_to_string()[source]

Convert complex query with AND, OR, and NOT subqueries to a string.

test_and_with_multiple_eq_parse()[source]

Test parsing an AND query with multiple equality subqueries.

test_and_with_multiple_eq_to_string()[source]

Convert query with multiple equality subqueries to a string.

test_and_with_multiple_gt_parse()[source]

Test parsing an AND query with multiple greater-than subqueries.

test_and_with_multiple_gt_to_string()[source]

Convert AND query with multiple greater-than subqueries to a string.

test_and_with_multiple_gte_parse()[source]

Test parsing an AND query with multiple greater-than-or-equal subqueries.

test_and_with_multiple_gte_to_string()[source]

Convert query with multiple greater-than-or-equal subqueries to a string.

test_and_with_multiple_in_parse()[source]

Test parsing an AND query with multiple IN subqueries.

test_and_with_multiple_in_to_string()[source]

Test converting an AND query with multiple IN subqueries to a string.

test_and_with_multiple_like_parse()[source]

Test parsing an AND query with multiple LIKE subqueries.

test_and_with_multiple_like_to_string()[source]

Test converting an AND query with multiple LIKE subqueries to a string.

test_and_with_multiple_lt_parse()[source]

Test parsing an AND query with multiple less-than subqueries.

test_and_with_multiple_lt_to_string()[source]

Convert query with multiple less-than subqueries to a string.

test_and_with_multiple_lte_parse()[source]

Test parsing an AND query with multiple less-than-or-equal subqueries.

test_and_with_multiple_lte_to_string()[source]

Convert query with multiple less-than-or-equal subqueries to a string.

test_and_with_multiple_mixed_parse()[source]

Test parsing an AND query with mixed subqueries.

test_and_with_multiple_mixed_to_string()[source]

Test converting an AND query with mixed subqueries to a string.

test_and_with_multiple_neq_parse()[source]

Test parsing an AND query with multiple inequality subqueries.

test_and_with_multiple_neq_to_string()[source]

Convert query with multiple inequality subqueries to a string.

test_and_with_multiple_not_eq_parse()[source]

Test parsing an AND query with multiple NOT equality subqueries.

test_and_with_multiple_not_eq_to_string()[source]

Convert query with multiple NOT equality subqueries to a string.

test_and_with_one_eq_parse()[source]

Test parsing an AND query with a single equality subquery.

test_and_with_one_eq_to_string()[source]

Test converting an AND query with a single equality subquery to a string.

test_and_with_one_gt_parse()[source]

Test parsing an AND query with a single greater-than subquery.

test_and_with_one_gt_to_string()[source]

Convert query with a single greater-than subquery to a string.

test_and_with_one_gte_parse()[source]

Test parsing an AND query with a single greater-than-or-equal subquery.

test_and_with_one_gte_to_string()[source]

Convert AND query with a single greater-than-or-equal subquery to a string.

test_and_with_one_in_parse()[source]

Test parsing an AND query with a single IN subquery.

test_and_with_one_in_to_string()[source]

Test converting an AND query with a single IN subquery to a string.

test_and_with_one_like_parse()[source]

Test parsing an AND query with a single LIKE subquery.

test_and_with_one_like_to_string()[source]

Test converting an AND query with a single LIKE subquery to a string.

test_and_with_one_lt_parse()[source]

Test parsing an AND query with a single less-than subquery.

test_and_with_one_lt_to_string()[source]

Convert AND query with a single less-than subquery to a string.

test_and_with_one_lte_parse()[source]

Test parsing an AND query with a single less-than-or-equal subquery.

test_and_with_one_lte_to_string()[source]

Convert AND query with a single less-than-or-equal subquery to a string.

test_and_with_one_neq_parse()[source]

Test parsing an AND query with a single inequality subquery.

test_and_with_one_neq_to_string()[source]

Test converting an AND query with a single inequality subquery to a string.

test_and_with_one_not_eq_parse()[source]

Test parsing an AND query with a single NOT equality subquery.

test_and_with_one_not_eq_to_string()[source]

Convert query with a single NOT equality subquery to a string.

test_exist_parse_array()[source]

Test parsing an EXIST query with multiple fields.

test_exist_parse_string()[source]

Test parsing an EXIST query with a single field.

test_not_with_one_eq_parse()[source]

Test parsing a NOT query with a single equality subquery.

test_not_with_one_eq_to_string()[source]

Test converting a NOT query with a single equality subquery to a string.

test_not_with_one_gt_parse()[source]

Test parsing a NOT query with a single greater-than subquery.

test_not_with_one_gt_to_string()[source]

Test converting a NOT query with a single greater-than subquery to a string.

test_not_with_one_gte_parse()[source]

Test parsing a NOT query with a single greater-than-or-equal subquery.

test_not_with_one_gte_to_string()[source]

Convert NOT query with a single greater-than-or-equal subquery to a string.

test_not_with_one_in_parse()[source]

Test parsing a NOT query with a single IN subquery.

test_not_with_one_in_to_string()[source]

Test converting a NOT query with a single IN subquery to a string.

test_not_with_one_like_parse()[source]

Test parsing a NOT query with a single LIKE subquery.

test_not_with_one_like_to_string()[source]

Test converting a NOT query with a single LIKE subquery to a string.

test_not_with_one_lt_parse()[source]

Test parsing a NOT query with a single less-than subquery.

test_not_with_one_lt_to_string()[source]

Test converting a NOT query with a single less-than subquery to a string.

test_not_with_one_lte_parse()[source]

Test parsing a NOT query with a single less-than-or-equal subquery.

test_not_with_one_lte_to_string()[source]

Convert NOT query with a single less-than-or-equal subquery to a string.

test_not_with_one_neq_parse()[source]

Test parsing a NOT query with a single inequality subquery.

test_not_with_one_neq_to_string()[source]

Test converting a NOT query with a single inequality subquery to a string.

test_old_format()[source]

Test parsing a query in the old format.

test_old_format_empty()[source]

Test parsing an empty query in the old format.

test_old_format_with_nulls()[source]

Test parsing a query in the old format with null values.

test_optimise_and()[source]

Test optimizing an empty AND query.

test_optimise_or()[source]

Test optimizing an empty OR query.

test_optimise_several_nested_and()[source]

Test optimizing several nested AND queries.

test_optimise_several_nested_or()[source]

Test optimizing several nested OR queries.

test_optimise_single_nested_and()[source]

Test optimizing a single nested AND query.

test_optimise_single_nested_or()[source]

Test optimizing a single nested OR query.

test_or_with_multiple_eq_parse()[source]

Test parsing an OR query with multiple equality subqueries.

test_or_with_multiple_eq_to_string()[source]

Test converting an OR query with multiple equality subqueries to a string.

test_or_with_multiple_gt_parse()[source]

Test parsing an OR query with multiple greater-than subqueries.

test_or_with_multiple_gt_to_string()[source]

Convert OR query with multiple greater-than subqueries to a string.

test_or_with_multiple_gte_parse()[source]

Test parsing an OR query with multiple greater-than-or-equal subqueries.

test_or_with_multiple_gte_to_string()[source]

Convert OR query with multiple greater-than-or-equal subqueries to a string.

test_or_with_multiple_in_parse()[source]

Test parsing an OR query with multiple IN subqueries.

test_or_with_multiple_in_to_string()[source]

Test converting an OR query with multiple IN subqueries to a string.

test_or_with_multiple_like_parse()[source]

Test parsing an OR query with multiple LIKE subqueries.

test_or_with_multiple_like_to_string()[source]

Test converting an OR query with multiple LIKE subqueries to a string.

test_or_with_multiple_lt_parse()[source]

Test parsing an OR query with multiple less-than subqueries.

test_or_with_multiple_lt_to_string()[source]

Convert OR query with multiple less-than subqueries to a str.

test_or_with_multiple_lte_parse()[source]

Test parsing an OR query with multiple less-than-or-equal subqueries.

test_or_with_multiple_lte_to_string()[source]

Convert OR query with multiple less-than-or-equal subqueries to a string.

test_or_with_multiple_mixed_parse()[source]

Test parsing an OR query with mixed subqueries.

test_or_with_multiple_mixed_to_string()[source]

Test converting an OR query with mixed subqueries to a string.

test_or_with_multiple_neq_parse()[source]

Test parsing an OR query with multiple inequality subqueries.

test_or_with_multiple_neq_to_string()[source]

Test converting an OR query with multiple inequality subqueries to a string.

test_or_with_multiple_not_eq_parse()[source]

Test parsing an OR query with multiple NOT equality subqueries.

test_or_with_multiple_not_eq_to_string()[source]

Convert OR query with multiple NOT equality subqueries to a string.

test_or_with_one_eq_parse()[source]

Test parsing an OR query with a single equality subquery.

test_or_with_one_eq_to_string()[source]

Test converting an OR query with a single equality subquery to a string.

test_or_with_one_gt_parse()[source]

Test parsing an OR query with a single greater-than subquery.

test_or_with_one_gt_to_string()[source]

Test converting an OR query with a single greater-than subquery to a string.

test_or_with_one_gte_parse()[source]

Test parsing an OR query with a single greater-than-or-equal subquery.

test_or_with_one_gte_to_string()[source]

Convert OR query with a single greater-than-or-equal subquery to a string.

test_or_with_one_in_parse()[source]

Test parsing an OR query with a single IN subquery.

test_or_with_one_in_to_string()[source]

Test converting an OR query with a single IN subquery to a string.

test_or_with_one_like_parse()[source]

Test parsing an OR query with a single LIKE subquery.

test_or_with_one_like_to_string()[source]

Test converting an OR query with a single LIKE subquery to a string.

test_or_with_one_lt_parse()[source]

Test parsing an OR query with a single less-than subquery.

test_or_with_one_lt_to_string()[source]

Test converting an OR query with a single less-than subquery to a string.

test_or_with_one_lte_parse()[source]

Test parsing an OR query with a single less-than-or-equal subquery.

test_or_with_one_lte_to_string()[source]

Convert OR query with a single less-than-or-equal subquery to a string.

test_or_with_one_neq_parse()[source]

Test parsing an OR query with a single inequality subquery.

test_or_with_one_neq_to_string()[source]

Convert OR query with a single inequality subquery to a string.

test_or_with_one_not_eq_parse()[source]

Test parsing an OR query with a single NOT equality subquery.

test_or_with_one_not_eq_to_string()[source]

Test converting an OR query with a single NOT equality subquery to a string.

test_short_and_with_multiple_eq_parse()[source]

Test parsing a short AND query with multiple equality subqueries.

test_simple_operator_empty_and_to_string()[source]

Test converting an empty AND query to a string.

test_simple_operator_empty_json_parse()[source]

Test parsing an empty JSON query.

test_simple_operator_empty_not_parse()[source]

Test parsing an empty NOT query.

test_simple_operator_empty_or_parse()[source]

Test parsing an empty OR query.

test_simple_operator_eq_parse()[source]

Test parsing a simple equality query.

test_simple_operator_eq_to_string()[source]

Test converting an equality query to a string.

test_simple_operator_eq_with_tilde_parse()[source]

Test parsing an equality query with ‘~’ prefix.

test_simple_operator_eq_with_tilde_to_string()[source]

Test converting an equality query with ‘~’ prefix to a string.

test_simple_operator_explicit_empty_and_parse()[source]

Test parsing an explicit empty AND query.

test_simple_operator_gt_parse()[source]

Test parsing a greater-than query.

test_simple_operator_gt_plaintext_to_string()[source]

Test converting a greater-than query to a string.

test_simple_operator_gte_parse()[source]

Test parsing a greater-than-or-equal query.

test_simple_operator_gte_to_string()[source]

Test converting a greater-than-or-equal query to a string.

test_simple_operator_in_multimply_to_string()[source]

Test converting an IN query with multiple values to a string.

test_simple_operator_in_multiple_parse()[source]

Test parsing an IN query with multiple values.

test_simple_operator_in_parse()[source]

Test parsing an IN query with a single value.

test_simple_operator_in_to_string()[source]

Test converting an IN query to a string.

test_simple_operator_like_parse()[source]

Test parsing a LIKE query.

test_simple_operator_like_to_string()[source]

Test converting a LIKE query to a string.

test_simple_operator_lt_parse()[source]

Test parsing a less-than query.

test_simple_operator_lt_to_string()[source]

Test converting a less-than query to a string.

test_simple_operator_lte_parse()[source]

Test parsing a less-than-or-equal query.

test_simple_operator_lte_to_string()[source]

Test converting a less-than-or-equal query to a string.

test_simple_operator_neq_parse()[source]

Test parsing a simple inequality query.

test_simple_operator_neq_to_string()[source]

Test converting an inequality query to a string.

acapy_agent.database_manager.wql_nosql.test_string_to_tagquery.random_string(length: int) str[source]

Generate a random string of given length.