kvesteri / sqlalchemy-utils

Various utility functions and datatypes for SQLAlchemy.
Other
1.25k stars 317 forks source link

Ltree.lca has confusing behavior wrt to the lca function provided by the ltree extension in postgres #468

Open abathur opened 4 years ago

abathur commented 4 years ago

I'm not sure if this is intended for some reason, or if people are depending on the inconsistent behavior, but the results returned by Ltree.lca don't agree with the postgresql function of the same name provided by the ltree extension:

postgres=# select lca('one.two'::ltree, 'one.two.three'::ltree, 'one.two.four'::ltree);
 lca 
-----
 one
(1 row)
>>> from sqlalchemy_utils import Ltree
>>> Ltree.lca(Ltree('one.two'), Ltree('one.two.three'), Ltree('one.two.four')) # finds no ancestor at all
>>> Ltree.lca(Ltree('one.two.five'), Ltree('one.two.three'), Ltree('one.two.four')) # but this does
Ltree('one.two')
kvesteri commented 4 years ago

PRs welcome