Skip to content

Fix: make unsupported comparisons return NotImplemented - #1199

Merged
robsdedude merged 3 commits into
neo4j:6.xfrom
robsdedude:fix/cmp-return-not-implemented
Jun 2, 2025
Merged

Fix: make unsupported comparisons return NotImplemented#1199
robsdedude merged 3 commits into
neo4j:6.xfrom
robsdedude:fix/cmp-return-not-implemented

Conversation

@robsdedude

Copy link
Copy Markdown
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)

@AndyHeap-NeoTech AndyHeap-NeoTech left a comment

Copy link
Copy Markdown
Contributor

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
@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