memgraph / gqlalchemy

GQLAlchemy is a library developed with the purpose of assisting in writing and running queries on Memgraph. GQLAlchemy supports high-level connection to Memgraph as well as modular query builder.

Home Page:https://pypi.org/project/gqlalchemy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Missing Cypher operators

philippe-bollard opened this issue · comments

Environment

  • GQLAlchemy 1.4.1
  • Python 3.9.2
  • Debian 11.7
  • Memgraph 2.9.0

Describe the bug
Some Cypher operators are missing from GQLAlchemy implementation.

I need to use the "=~" operator for a pattern matching query but it's not declared in the enumeration :
https://github.com/memgraph/gqlalchemy/blob/main/gqlalchemy/query_builders/declarative_base.py#L84

Sadly, it's not possible to build the query without the enum due to this line :
https://github.com/memgraph/gqlalchemy/blob/main/gqlalchemy/query_builders/declarative_base.py#L184

To Reproduce

Instead of pasting here a lot of my application code, please find below an unstested example adapted from https://memgraph.com/docs/cypher-manual/clauses/where#3-regular-expressions

  1. Build a query using the string '=~' in place of the missing enum operator

query = match().node(labels="Person", variable="n").where(item="n.name", operator="=~", literal=".*a$").return("n")

  1. Run it

query.execute()

  1. It will raise that kind of exception

[...] File "/home/philippe/.local/share/virtualenvs/Engine-tgOo-fyU/lib/python3.9/site-packages/gqlalchemy/query_builders/declarative_base.py", line 950, in and_where self._query.append(AndWhereConditionPartialQuery(item=item, operator=operator, **kwargs)) File "/home/philippe/.local/share/virtualenvs/Engine-tgOo-fyU/lib/python3.9/site-packages/gqlalchemy/query_builders/declarative_base.py", line 212, in __init__ super().__init__(item=item, operator=operator, keyword=Where.AND, **kwargs) File "/home/philippe/.local/share/virtualenvs/Engine-tgOo-fyU/lib/python3.9/site-packages/gqlalchemy/query_builders/declarative_base.py", line 172, in __init__ self.query = self._build_where_query(item=item, operator=operator, **kwargs) File "/home/philippe/.local/share/virtualenvs/Engine-tgOo-fyU/lib/python3.9/site-packages/gqlalchemy/query_builders/declarative_base.py", line 186, in _build_where_query raise GQLAlchemyOperatorTypeError(clause=self.type) gqlalchemy.exceptions.GQLAlchemyOperatorTypeError

Expected behavior

A full support by GQLAlchemy of all Cypher operators (and all related syntax)

Additional context

Patching the enum (declared at https://github.com/memgraph/gqlalchemy/blob/main/gqlalchemy/query_builders/declarative_base.py#L84) allows to build and run properly a query containing a regex.

Hi @philippe-bollard and thank you for opening the issue 🙏 We are aware that the whole Cypher still isn't supported, and I agree it should be expanded. I can't tell you when this will be worked on since we need to prioritize first. Is this a blocking issue for you or did you manage to continue using Memgraph regardless of that? Are you running Memgraph in production?

@imilinovic is #304 fully resolving this issue?