diff --git a/sqlalchemy_utils/primitives/ltree.py b/sqlalchemy_utils/primitives/ltree.py index 5ca1448..e330259 100644 --- a/sqlalchemy_utils/primitives/ltree.py +++ b/sqlalchemy_utils/primitives/ltree.py @@ -81,7 +81,7 @@ class Ltree(object): assert Ltree('1.2.3.4.5').lca('1.2', '1.2.3') == '1' - Ltree objects can be concatenated.1 + Ltree objects can be concatenated. :: diff --git a/sqlalchemy_utils/types/ltree.py b/sqlalchemy_utils/types/ltree.py index 95ebfcb..49c07a6 100644 --- a/sqlalchemy_utils/types/ltree.py +++ b/sqlalchemy_utils/types/ltree.py @@ -19,6 +19,24 @@ class LtreeType(types.Concatenable, types.UserDefinedType, ScalarCoercible): in hierarchial tree-like structure. For more detailed information please refer to http://www.postgresql.org/docs/current/static/ltree.html + :: + + from sqlalchemy_utils import LtreeType + + + class DocumentSection(Base): + __tablename__ = 'document_section' + id = sa.Column(sa.Integer, autoincrement=True) + path = sa.Column(LtreeType) + + + section = DocumentSection(name='Countries.Finland') + session.add(section) + session.commit() + + section.path # Ltree('Countries.Finland') + + .. note:: Using :class:`LtreeType`, :class:`LQUERY` and :class:`LTXTQUERY` types may require installation of Postgresql ltree extension on the server