本文整理汇总了Python中sqlalchemy.engine.default.StrCompileDialect方法的典型用法代码示例。如果您正苦于以下问题:Python default.StrCompileDialect方法的具体用法?Python default.StrCompileDialect怎么用?Python default.StrCompileDialect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.engine.default
的用法示例。
在下文中一共展示了default.StrCompileDialect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_autocorrelate_error
# 需要导入模块: from sqlalchemy.engine import default [as 别名]
# 或者: from sqlalchemy.engine.default import StrCompileDialect [as 别名]
def test_autocorrelate_error(self):
users, addresses = self.tables.users, self.tables.addresses
stmt = (
users.update()
.values(name="newname")
.where(users.c.id == addresses.c.user_id)
.where(
~exists()
.where(addresses.c.user_id == users.c.id)
.where(addresses.c.email_address == "foo")
)
)
assert_raises_message(
exc.InvalidRequestError,
".*returned no FROM clauses due to auto-correlation.*",
stmt.compile,
dialect=default.StrCompileDialect(),
)
示例2: test_autocorrelate_error
# 需要导入模块: from sqlalchemy.engine import default [as 别名]
# 或者: from sqlalchemy.engine.default import StrCompileDialect [as 别名]
def test_autocorrelate_error(self):
table1, table2 = self.tables.mytable, self.tables.myothertable
stmt = (
table1.delete()
.where(table1.c.myid == table2.c.otherid)
.where(
~exists()
.where(table2.c.otherid == table1.c.myid)
.where(table2.c.othername == "x")
)
)
assert_raises_message(
exc.InvalidRequestError,
".*returned no FROM clauses due to auto-correlation.*",
stmt.compile,
dialect=default.StrCompileDialect(),
)
示例3: test_update_bound_ordering
# 需要导入模块: from sqlalchemy.engine import default [as 别名]
# 或者: from sqlalchemy.engine.default import StrCompileDialect [as 别名]
def test_update_bound_ordering(self):
"""test that bound parameters between the UPDATE and FROM clauses
order correctly in different SQL compilation scenarios.
"""
table1 = self.tables.mytable
table2 = self.tables.myothertable
sel = select([table2]).where(table2.c.otherid == 5).alias()
upd = (
table1.update()
.where(table1.c.name == sel.c.othername)
.values(name="foo")
)
dialect = default.StrCompileDialect()
dialect.positional = True
self.assert_compile(
upd,
"UPDATE mytable SET name=:name FROM (SELECT "
"myothertable.otherid AS otherid, "
"myothertable.othername AS othername "
"FROM myothertable "
"WHERE myothertable.otherid = :otherid_1) AS anon_1 "
"WHERE mytable.name = anon_1.othername",
checkpositional=("foo", 5),
dialect=dialect,
)
self.assert_compile(
upd,
"UPDATE mytable, (SELECT myothertable.otherid AS otherid, "
"myothertable.othername AS othername "
"FROM myothertable "
"WHERE myothertable.otherid = %s) AS anon_1 SET mytable.name=%s "
"WHERE mytable.name = anon_1.othername",
checkpositional=(5, "foo"),
dialect=mysql.dialect(),
)