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')
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: