-
Notifications
You must be signed in to change notification settings - Fork 332
Description
While testing an isolated copy of the Ltree implementation, an AI assistant (Claude-Sonnet via Cursor) identified what might be unexpected behavior in the lca()
method when one path is a prefix of another.
Example:
ltree = Ltree('1.2.3.4.5')
result = ltree.lca('1.2.3', '1.2.3.4')
print(result) # Returns Ltree('1.2') but expected Ltree('1.2.3')
The current implementation appears to stop at '1.2' because it hits the condition:
len(other) <= index + 1
when processing the shorter path '1.2.3'.
However, since '1.2.3' is a valid prefix shared by all paths in the example, it seems this should be the LCA.
Important Note: This behavior was identified through unit testing, but I haven't verified if this aligns with or differs from PostgreSQL's native ltree implementation. If this behavior is intentionally matching PostgreSQL's ltree module, please disregard this report.
Would appreciate confirmation whether this is:
- Expected behavior matching PostgreSQL
- A legitimate issue
- Working as intended for other reasons
Thank you for maintaining this useful library!