operations.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Callandtext 作者: iaora 项目源码 文件源码
def _foreign_key_constraint(self, name, source, referent,
                                local_cols, remote_cols,
                                onupdate=None, ondelete=None,
                                deferrable=None, source_schema=None,
                                referent_schema=None, initially=None,
                                match=None, **dialect_kw):
        m = self._metadata()
        if source == referent:
            t1_cols = local_cols + remote_cols
        else:
            t1_cols = local_cols
            sa_schema.Table(
                referent, m,
                *[sa_schema.Column(n, NULLTYPE) for n in remote_cols],
                schema=referent_schema)

        t1 = sa_schema.Table(
            source, m,
            *[sa_schema.Column(n, NULLTYPE) for n in t1_cols],
            schema=source_schema)

        tname = "%s.%s" % (referent_schema, referent) if referent_schema \
                else referent

        if util.sqla_08:
            # "match" kw unsupported in 0.7
            dialect_kw['match'] = match

        f = sa_schema.ForeignKeyConstraint(local_cols,
                                           ["%s.%s" % (tname, n)
                                            for n in remote_cols],
                                           name=name,
                                           onupdate=onupdate,
                                           ondelete=ondelete,
                                           deferrable=deferrable,
                                           initially=initially,
                                           **dialect_kw
                                           )
        t1.append_constraint(f)

        return f
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号