Skip to content

Fix: make unsupported comparisons return NotImplemented #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2025

Conversation

robsdedude
Copy link
Member

Make all comparator magic methods return NotImplemented instead of False (or raising TypeError in some instances) if the other operand is not of a supported type.

This means that when comparing a driver type with another type is doesn't support, the other type get the chance to handle the comparison.

Affected types:

  • neo4j.Record
  • neo4j.graph.Node, neo4j.graph.Relationship, neo4j.graph.Path
  • neo4j.time.Date, neo4j.time.Time, neo4j.time.DateTime
  • neo4j.spatial.Point (and subclasses)

Make all comparator magic methods return `NotImplemented` instead of `False`
(or raising `TypeError` in some instances) if the other operand is not of a
supported type.

This means that when comparing a driver type with another type is doesn't
support, the other type get the chance to handle the comparison.

Affected types:
 * `neo4j.Record`
 * `neo4j.graph.Node`, `neo4j.graph.Relationship`, `neo4j.graph.Path`
 * `neo4j.time.Date`, `neo4j.time.Time`, `neo4j.time.DateTime`
 * `neo4j.spatial.Point` (and subclasses)
Copy link
Contributor

@AndyHeap-NeoTech AndyHeap-NeoTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct.

@robsdedude robsdedude merged commit ce45656 into neo4j:6.x Jun 2, 2025
20 checks passed
@robsdedude robsdedude deleted the fix/cmp-return-not-implemented branch June 2, 2025 16:12
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.

2 participants