summaryrefslogtreecommitdiff
path: root/test/testbase.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-04-18 22:33:53 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-04-18 22:33:53 +0000
commit7efd23b23cbbd1d714cc31e44e776b7e1e9af319 (patch)
tree9785dee17451fb928446af8034ce8ceabfe74a09 /test/testbase.py
parentd5c3eb39ca6e6738d16e8013fd5cb46b17486d5a (diff)
downloadsqlalchemy-7efd23b23cbbd1d714cc31e44e776b7e1e9af319.tar.gz
- fixed critical issue when, after options(eagerload()) is used,
the mapper would then always apply query "wrapping" behavior for all subsequent LIMIT/OFFSET/DISTINCT queries, even if no eager loading was applied on those subsequent queries.
Diffstat (limited to 'test/testbase.py')
-rw-r--r--test/testbase.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/testbase.py b/test/testbase.py
index aae455673..1bcc5c142 100644
--- a/test/testbase.py
+++ b/test/testbase.py
@@ -224,6 +224,17 @@ class AssertMixin(PersistTest):
finally:
self.assert_(testdata.sql_count == count, "desired statement count %d does not match %d" % (count, testdata.sql_count))
+ def capture_sql(self, db, callable_):
+ global testdata
+ testdata = TestData(db)
+ buffer = StringIO.StringIO()
+ testdata.buffer = buffer
+ try:
+ callable_()
+ return buffer.getvalue()
+ finally:
+ testdata.buffer = None
+
class ORMTest(AssertMixin):
keep_mappers = False
keep_data = False
@@ -251,6 +262,7 @@ class TestData(object):
self.logger = engine.logger
self.set_assert_list(None, None)
self.sql_count = 0
+ self.buffer = None
def set_assert_list(self, unittest, list):
self.unittest = unittest
@@ -270,6 +282,8 @@ class ExecutionContextWrapper(object):
ctx = self.ctx
statement = unicode(ctx.compiled)
statement = re.sub(r'\n', '', ctx.statement)
+ if testdata.buffer is not None:
+ testdata.buffer.write(statement + "\n")
if testdata.assert_list is not None:
item = testdata.assert_list[-1]