test_types_extras.py 文件源码

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

项目:psycopg2-for-aws-lambda 作者: iwitaly 项目源码 文件源码
def testUUIDARRAY(self):
        import uuid
        psycopg2.extras.register_uuid()
        u = [uuid.UUID('9c6d5a77-7256-457e-9461-347b4358e350'),
             uuid.UUID('9c6d5a77-7256-457e-9461-347b4358e352')]
        s = self.execute("SELECT %s AS foo", (u,))
        self.assertTrue(u == s)
        # array with a NULL element
        u = [uuid.UUID('9c6d5a77-7256-457e-9461-347b4358e350'), None]
        s = self.execute("SELECT %s AS foo", (u,))
        self.assertTrue(u == s)
        # must survive NULL cast to a uuid[]
        s = self.execute("SELECT NULL::uuid[] AS foo")
        self.assertTrue(s is None)
        # what about empty arrays?
        s = self.execute("SELECT '{}'::uuid[] AS foo")
        self.assertTrue(type(s) == list and len(s) == 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号