Python sqlalchemy.engine.default.StrCompileDialect() Examples
The following are 3
code examples of sqlalchemy.engine.default.StrCompileDialect().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.engine.default
, or try the search function
.
Example #1
Source File: test_update.py From sqlalchemy with MIT License | 6 votes |
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(), )
Example #2
Source File: test_delete.py From sqlalchemy with MIT License | 6 votes |
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(), )
Example #3
Source File: test_update.py From sqlalchemy with MIT License | 5 votes |
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(), )