sqlalchemy.__version__.startswith

Here are the examples of the python api sqlalchemy.__version__.startswith taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

0 Source : __init__.py
with Apache License 2.0
from insitro

    def children(self) -> List["CallNode"]:
        if sa.__version__.startswith("1.3."):
            child_nodes = (
                object_session(self)
                .query(CallNode)
                .join(CallEdge, CallEdge.child_id == CallNode.call_hash)
                .filter(CallEdge.parent_id == self.call_hash)
            )
            # https://github.com/sqlalchemy/sqlalchemy/issues/4395
            child_nodes._has_mapper_entities = False
            return child_nodes.all()

        else:
            # New style available in sqlalchemy>=1.4.0
            # https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#joinedload-not-uniqued
            child_nodes = object_session(self).execute(
                select(CallNode)
                .join(CallEdge, CallEdge.child_id == CallNode.call_hash)
                .filter(CallEdge.parent_id == self.call_hash)
                .order_by(CallEdge.call_order)
            )
            return [node for (node,) in child_nodes]

    @property

0 Source : __init__.py
with Apache License 2.0
from insitro

    def parents(self) -> List["CallNode"]:
        if sa.__version__.startswith("1.3."):
            parent_nodes = (
                object_session(self)
                .query(CallNode)
                .join(CallEdge, CallEdge.parent_id == CallNode.call_hash)
                .filter(CallEdge.child_id == self.call_hash)
            )
            # https://github.com/sqlalchemy/sqlalchemy/issues/4395
            parent_nodes._has_mapper_entities = False
            return parent_nodes.all()

        else:
            # New style available in sqlalchemy>=1.4.0
            # https://docs.sqlalchemy.org/en/14/changelog/migration_20.html#joinedload-not-uniqued
            parent_nodes = object_session(self).execute(
                select(CallNode)
                .join(CallEdge, CallEdge.parent_id == CallNode.call_hash)
                .filter(CallEdge.child_id == self.call_hash)
                .order_by(CallEdge.call_order)
            )
            return [node for (node,) in parent_nodes]

    @property