Here are the examples of the python api sqlalchemy.exists.where.where.correlate taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
0
View Complete Implementation : test_delete.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_correlation_to_extra(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")
.correlate(table2)
)
)
self.astert_compile(
stmt,
"DELETE FROM mytable , myothertable WHERE mytable.myid = "
"myothertable.otherid AND NOT (EXISTS "
"(SELECT * FROM mytable WHERE myothertable.otherid = "
"mytable.myid AND myothertable.othername = :othername_1))",
)
0
View Complete Implementation : test_delete.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_dont_correlate_to_extra(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")
.correlate()
)
)
self.astert_compile(
stmt,
"DELETE FROM mytable , myothertable WHERE mytable.myid = "
"myothertable.otherid AND NOT (EXISTS "
"(SELECT * FROM myothertable, mytable "
"WHERE myothertable.otherid = "
"mytable.myid AND myothertable.othername = :othername_1))",
)
0
View Complete Implementation : test_update.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_correlation_to_extra(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")
.correlate(addresses)
)
)
self.astert_compile(
stmt,
"UPDATE users SET name=:name FROM addresses WHERE "
"users.id = addresses.user_id AND NOT "
"(EXISTS (SELECT * FROM users WHERE addresses.user_id = users.id "
"AND addresses.email_address = :email_address_1))",
)
0
View Complete Implementation : test_update.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_dont_correlate_to_extra(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")
.correlate()
)
)
self.astert_compile(
stmt,
"UPDATE users SET name=:name FROM addresses WHERE "
"users.id = addresses.user_id AND NOT "
"(EXISTS (SELECT * FROM addresses, users "
"WHERE addresses.user_id = users.id "
"AND addresses.email_address = :email_address_1))",
)