summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-06-14 15:39:46 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-06-14 15:39:46 +0000
commit0642dcb796313118dd81c3d12e044b4128c2746d (patch)
tree447482200cf38c712e8ff375179f9e06202cf8fc /test
parent6f8459c313163f46a0bcccc6cd8eda1fd2058d57 (diff)
downloadsqlalchemy-0642dcb796313118dd81c3d12e044b4128c2746d.tar.gz
unit tests for dangling subquery, many-to-many clear-and-resave
Diffstat (limited to 'test')
-rw-r--r--test/orm/objectstore.py36
-rw-r--r--test/sql/select.py5
2 files changed, 41 insertions, 0 deletions
diff --git a/test/orm/objectstore.py b/test/orm/objectstore.py
index 83d279a28..4dc9624a9 100644
--- a/test/orm/objectstore.py
+++ b/test/orm/objectstore.py
@@ -1027,6 +1027,42 @@ class SaveTest(SessionTest):
ctx.current.delete(objects[3])
ctx.current.flush()
+
+
+ def testmanytomanyupdate(self):
+ class Keyword(object):
+ def __init__(self, name):
+ self.name = name
+ def __eq__(self, other):
+ return other.name == self.name
+ def __repr__(self):
+ return "Keyword(%s, %s)" % (getattr(self, 'keyword_id', 'None'), self.name)
+
+ mapper(Keyword, keywords)
+ mapper(Item, orderitems, properties = dict(
+ keywords = relation(Keyword, secondary=itemkeywords, lazy=False),
+ ))
+
+ (k1, k2, k3) = (Keyword('keyword 1'), Keyword('keyword 2'), Keyword('keyword 3'))
+ item = Item()
+ item.item_name = 'item 1'
+ item.keywords.append(k1)
+ item.keywords.append(k2)
+ item.keywords.append(k3)
+ ctx.current.flush()
+
+ item.keywords = []
+ item.keywords.append(k1)
+ item.keywords.append(k2)
+ print item.keywords.unchanged_items()
+ print item.keywords.added_items()
+ print item.keywords.deleted_items()
+ ctx.current.flush()
+
+ ctx.current.clear()
+ item = ctx.current.query(Item).get(item.item_id)
+ print [k1, k2]
+ assert item.keywords == [k1, k2]
def testassociation(self):
class IKAssociation(object):
diff --git a/test/sql/select.py b/test/sql/select.py
index 2481e04ae..290e324cf 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -124,6 +124,11 @@ sq.mytable_description AS sq_mytable_description, sq.myothertable_otherid AS sq_
sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") AS sq) AS sq2")
def testwheresubquery(self):
+ # TODO: this tests that you dont get a "SELECT column" without a FROM but its not working yet.
+ #self.runtest(
+ # table1.select(table1.c.myid == select([table1.c.myid], table1.c.name=='jack')), ""
+ #)
+
self.runtest(
table1.select(table1.c.myid == select([table2.c.otherid], table1.c.name == table2.c.othername)),
"SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid = (SELECT myothertable.otherid AS otherid FROM myothertable WHERE mytable.name = myothertable.othername)"