Skip to content

Add IS NOT NULL operator to query builder#390

Open
syzayd wants to merge 1 commit into
memgraph:mainfrom
syzayd:add-is-not-null-operator
Open

Add IS NOT NULL operator to query builder#390
syzayd wants to merge 1 commit into
memgraph:mainfrom
syzayd:add-is-not-null-operator

Conversation

@syzayd

@syzayd syzayd commented Jul 7, 2026

Copy link
Copy Markdown

Closes #293.

What

Adds Operator.IS_NOT_NULL to the query builder, so property-existence filters can be expressed:

match().node(variable="n").to().node(variable="m").where(item="n.name", operator=Operator.IS_NOT_NULL).return_()
MATCH (n)-[]->(m) WHERE n.name IS NOT NULL RETURN *;

How

IS NOT NULL is the query builder's first unary (postfix) operator, so besides the enum entry, WhereConditionPartialQuery._build_where_query gains a small unary branch:

  • unary operators require neither literal nor expression; the condition is rendered as item IS NOT NULL
  • passing literal or expression with a unary operator raises GQLAlchemyExtraKeywordArguments, consistent with the existing "extra keyword arguments" semantics
  • the unary set is a class constant (_UNARY_OPERATORS), so a future IS NULL is a two-line follow-up - happy to add it in this PR if you want the symmetric operator too

Tests and docs

  • test_where_is_not_null, test_and_where_is_not_null (chaining), plus two error-path tests for literal/expression misuse - same style as the recently merged IN operator tests (Add IN operator to query builder #379)
  • where() docstring updated and an IS NOT NULL section added to the query-builder how-to guide, mirroring the IN section
  • ran pytest tests/query_builders/test_query_builders.py plus black --check and flake8 on the touched files locally - all green

Note

#293 shows a 2024 assignment; since the issue is still open with recent community interest and no linked PR, I hope a community contribution is welcome - happy to defer or adjust if work is already underway.

Adds Operator.IS_NOT_NULL as the query builder's first unary (postfix)
operator: where() takes neither literal nor expression for it, and
passing either raises GQLAlchemyExtraKeywordArguments. Includes tests
mirroring the IN operator's, a docstring update, and a how-to guide
section.

Closes memgraph#293

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FTdT6AcZMfnUfhiNA92T5e
@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IS NOT NULL to query builder

2 participants