當前位置: 首頁>>代碼示例>>Python>>正文


Python orm.remote方法代碼示例

本文整理匯總了Python中sqlalchemy.orm.remote方法的典型用法代碼示例。如果您正苦於以下問題:Python orm.remote方法的具體用法?Python orm.remote怎麽用?Python orm.remote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sqlalchemy.orm的用法示例。


在下文中一共展示了orm.remote方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _join_fixture_remote_local_multiple_ref

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _join_fixture_remote_local_multiple_ref(self, **kw):
        def fn(a, b):
            return (a == b) | (b == a)

        return relationships.JoinCondition(
            self.selfref,
            self.selfref,
            self.selfref,
            self.selfref,
            support_sync=False,
            primaryjoin=fn(
                # we're putting a do-nothing annotation on
                # "a" so that the left/right is preserved;
                # annotation vs. non seems to affect __eq__ behavior
                self.selfref.c.sid._annotate({"foo": "bar"}),
                foreign(remote(self.selfref.c.sid)),
            ),
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:20,代碼來源:test_rel_fn.py

示例2: test_pj_deannotates

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def test_pj_deannotates(self):
        from sqlalchemy.ext.declarative import declarative_base

        Base = declarative_base()

        class A(Base):
            __tablename__ = "a"
            id = Column(Integer, primary_key=True)

        class B(Base):
            __tablename__ = "b"
            id = Column(Integer, primary_key=True)
            a_id = Column(ForeignKey(A.id))
            a = relationship(A)

        eq_(
            B.a.property.primaryjoin.left._annotations,
            {"parentmapper": A.__mapper__, "remote": True},
        )
        eq_(
            B.a.property.primaryjoin.right._annotations,
            {"foreign": True, "local": True, "parentmapper": B.__mapper__},
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:25,代碼來源:test_rel_fn.py

示例3: _descendants_fixture

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _descendants_fixture(self, data=True):
        Entity = self.classes.Entity
        entity = self.tables.entity

        m = mapper(
            Entity,
            entity,
            properties={
                "descendants": relationship(
                    Entity,
                    primaryjoin=remote(foreign(entity.c.path)).like(
                        entity.c.path.concat("/%")
                    ),
                    viewonly=True,
                    order_by=entity.c.path,
                )
            },
        )
        configure_mappers()
        assert m.get_property("descendants").direction is ONETOMANY
        if data:
            return self._fixture() 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:24,代碼來源:test_relationships.py

示例4: setup_classes

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def setup_classes(cls):
        Base = cls.DeclarativeBasic

        class Venue(Base):
            __tablename__ = "venue"
            id = Column(Integer, primary_key=True)
            name = Column(String)

            descendants = relationship(
                "Venue",
                primaryjoin=func.instr(
                    remote(foreign(name)), name + "/"
                ).as_comparison(1, 2)
                == 1,
                viewonly=True,
                order_by=name,
            ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:19,代碼來源:test_relationships.py

示例5: _resolver

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _resolver(cls, prop):
    import sqlalchemy
    from sqlalchemy.orm import foreign, remote

    fallback = sqlalchemy.__dict__.copy()
    fallback.update({'foreign': foreign, 'remote': remote})

    def resolve_arg(arg):
        return _class_resolver(cls, prop, fallback, arg)
    return resolve_arg 
開發者ID:jpush,項目名稱:jbox,代碼行數:12,代碼來源:clsregistry.py

示例6: setup_listener

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def setup_listener(mapper, class_):
    name = class_.__name__
    discriminator = name.lower()
    class_.addresses = relationship(
        Address,
        primaryjoin=and_(
            class_.id == foreign(remote(Address.parent_id)),
            Address.discriminator == discriminator,
        ),
        backref=backref(
            "parent_%s" % discriminator,
            primaryjoin=remote(class_.id) == foreign(Address.parent_id),
        ),
    )

    @event.listens_for(class_.addresses, "append")
    def append_address(target, value, initiator):
        value.discriminator = discriminator 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:20,代碼來源:generic_fk.py

示例7: _resolver

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _resolver(cls, prop):
    import sqlalchemy
    from sqlalchemy.orm import foreign, remote

    fallback = sqlalchemy.__dict__.copy()
    fallback.update({"foreign": foreign, "remote": remote})

    def resolve_arg(arg):
        return _class_resolver(cls, prop, fallback, arg)

    def resolve_name(arg):
        return _class_resolver(cls, prop, fallback, arg)._resolve_name

    return resolve_name, resolve_arg 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:16,代碼來源:clsregistry.py

示例8: _join_fixture_o2m_composite_selfref_func_annotated

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _join_fixture_o2m_composite_selfref_func_annotated(self, **kw):
        return relationships.JoinCondition(
            self.composite_selfref,
            self.composite_selfref,
            self.composite_selfref,
            self.composite_selfref,
            primaryjoin=and_(
                remote(self.composite_selfref.c.group_id)
                == func.foo(self.composite_selfref.c.group_id),
                remote(self.composite_selfref.c.parent_id)
                == self.composite_selfref.c.id,
            ),
            **kw
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:16,代碼來源:test_rel_fn.py

示例9: _join_fixture_compound_expression_1

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _join_fixture_compound_expression_1(self, **kw):
        return relationships.JoinCondition(
            self.left,
            self.right,
            self.left,
            self.right,
            primaryjoin=(self.left.c.x + self.left.c.y)
            == relationships.remote(
                relationships.foreign(self.right.c.x * self.right.c.y)
            ),
            **kw
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:14,代碼來源:test_rel_fn.py

示例10: _join_fixture_purely_single_o2m

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _join_fixture_purely_single_o2m(self, **kw):
        return relationships.JoinCondition(
            self.purely_single_col,
            self.purely_single_col,
            self.purely_single_col,
            self.purely_single_col,
            support_sync=False,
            primaryjoin=self.purely_single_col.c.path.like(
                remote(foreign(self.purely_single_col.c.path.concat("%")))
            ),
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:13,代碼來源:test_rel_fn.py

示例11: _assert_non_simple_warning

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _assert_non_simple_warning(self, fn):
        assert_raises_message(
            exc.SAWarning,
            "Non-simple column elements in "
            "primary join condition for property "
            r"None - consider using remote\(\) "
            "annotations to mark the remote side.",
            fn,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:11,代碼來源:test_rel_fn.py

示例12: _assert_raises_no_local_remote

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def _assert_raises_no_local_remote(self, fn, relname, *arg, **kw):
        assert_raises_message(
            sa.exc.ArgumentError,
            "Relationship %s could not determine "
            "any unambiguous local/remote column "
            "pairs based on join condition and remote_side arguments.  "
            r"Consider using the remote\(\) annotation to "
            "accurately mark those elements of the join "
            "condition that are on the remote side of the relationship."
            % (relname),
            fn,
            *arg,
            **kw
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:16,代碼來源:test_relationships.py

示例13: test_annotated

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def test_annotated(self):
        Employee, Company, employee_t, company_t = (
            self.classes.Employee,
            self.classes.Company,
            self.tables.employee_t,
            self.tables.company_t,
        )

        mapper(Company, company_t)
        mapper(
            Employee,
            employee_t,
            properties={
                "company": relationship(Company, backref="employees"),
                "reports_to": relationship(
                    Employee,
                    primaryjoin=sa.and_(
                        remote(employee_t.c.emp_id)
                        == employee_t.c.reports_to_id,
                        remote(employee_t.c.company_id)
                        == employee_t.c.company_id,
                    ),
                    backref=backref("employees"),
                ),
            },
        )

        self._assert_lazy_clauses()
        self._test() 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:31,代碼來源:test_relationships.py

示例14: test_overlapping_warning

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def test_overlapping_warning(self):
        Employee, Company, employee_t, company_t = (
            self.classes.Employee,
            self.classes.Company,
            self.tables.employee_t,
            self.tables.company_t,
        )

        mapper(Company, company_t)
        mapper(
            Employee,
            employee_t,
            properties={
                "company": relationship(Company, backref="employees"),
                "reports_to": relationship(
                    Employee,
                    primaryjoin=sa.and_(
                        remote(employee_t.c.emp_id)
                        == employee_t.c.reports_to_id,
                        remote(employee_t.c.company_id)
                        == employee_t.c.company_id,
                    ),
                    backref=backref("employees"),
                ),
            },
        )

        assert_raises_message(
            exc.SAWarning,
            r"relationship .* will copy column .* to column "
            r"employee_t.company_id, which conflicts with relationship\(s\)",
            configure_mappers,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:35,代碼來源:test_relationships.py

示例15: test_annotated_no_overwriting

# 需要導入模塊: from sqlalchemy import orm [as 別名]
# 或者: from sqlalchemy.orm import remote [as 別名]
def test_annotated_no_overwriting(self):
        Employee, Company, employee_t, company_t = (
            self.classes.Employee,
            self.classes.Company,
            self.tables.employee_t,
            self.tables.company_t,
        )

        mapper(Company, company_t)
        mapper(
            Employee,
            employee_t,
            properties={
                "company": relationship(Company, backref="employees"),
                "reports_to": relationship(
                    Employee,
                    primaryjoin=sa.and_(
                        remote(employee_t.c.emp_id)
                        == foreign(employee_t.c.reports_to_id),
                        remote(employee_t.c.company_id)
                        == employee_t.c.company_id,
                    ),
                    backref=backref("employees"),
                ),
            },
        )

        self._assert_lazy_clauses()
        self._test_no_warning() 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:31,代碼來源:test_relationships.py


注:本文中的sqlalchemy.orm.remote方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。