[CalendarServer-changes] [8441] CalendarServer/branches/users/glyph/shared-pool-fixes
source_changes at macosforge.org
source_changes at macosforge.org
Tue Dec 13 13:50:58 PST 2011
Revision: 8441
http://trac.macosforge.org/projects/calendarserver/changeset/8441
Author: glyph at apple.com
Date: 2011-12-13 13:50:58 -0800 (Tue, 13 Dec 2011)
Log Message:
-----------
deal with None results from non-queries consistently, and test (and fix) for the case where no Return is passed to an Oracle INSERT
Modified Paths:
--------------
CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/adbapi2.py
CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/syntax.py
CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/test/test_sqlsyntax.py
Property Changed:
----------------
CalendarServer/branches/users/glyph/shared-pool-fixes/
Modified: CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/adbapi2.py
===================================================================
--- CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/adbapi2.py 2011-12-13 21:50:54 UTC (rev 8440)
+++ CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/adbapi2.py 2011-12-13 21:50:58 UTC (rev 8441)
@@ -1150,7 +1150,8 @@
arguments = [('queryID', String()),
('norows', Boolean()),
- ('derived', Pickle())]
+ ('derived', Pickle()),
+ ('noneResult', Boolean())]
errors = quashErrors
@@ -1224,6 +1225,7 @@
@inlineCallbacks
def receivedSQL(self, transactionID, queryID, sql, args, blockID):
derived = None
+ noneResult = False
for param in args:
if IDerivedParameter.providedBy(param):
if derived is None:
@@ -1244,9 +1246,11 @@
# Either this should be yielded or it should be
# requiresAnswer=False
self.callRemote(Row, queryID=queryID, row=row)
+ else:
+ noneResult = True
self.callRemote(QueryComplete, queryID=queryID, norows=norows,
- derived=derived)
+ derived=derived, noneResult=noneResult)
returnValue({})
@@ -1326,8 +1330,8 @@
@failsafeResponder(QueryComplete)
- def complete(self, queryID, norows, derived):
- self._queries.pop(queryID).done(norows, derived)
+ def complete(self, queryID, norows, derived, noneResult):
+ self._queries.pop(queryID).done(norows, derived, noneResult)
return {}
@@ -1347,7 +1351,7 @@
self.results.append(row)
- def done(self, norows, derived):
+ def done(self, norows, derived, noneResult):
"""
The query is complete.
@@ -1360,7 +1364,14 @@
and L{IDerivedParameter.postQuery} are invoked on the other end of
the wire, the local objects will be made to appear as though they
were called here.
+
+ @param noneResult: should the result of the query be C{None} (i.e. did
+ it not have a C{description} on the cursor).
"""
+ if noneResult and not self.results:
+ results = None
+ else:
+ results = self.results
if derived is not None:
# 1) Bleecchh.
# 2) FIXME: add some direct tests in test_adbapi2, the unit test for
@@ -1373,7 +1384,7 @@
exc = self.raiseOnZeroRowCount()
self.deferred.errback(Failure(exc))
else:
- self.deferred.callback(self.results)
+ self.deferred.callback(results)
def _deriveDerived(self):
Modified: CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/syntax.py 2011-12-13 21:50:54 UTC (rev 8440)
+++ CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/syntax.py 2011-12-13 21:50:58 UTC (rev 8441)
@@ -981,6 +981,8 @@
def _extraVars(self, txn, metadata):
+ if self.Return is None:
+ return []
result = []
rvars = self._returnAsList()
if metadata.dialect == ORACLE_DIALECT:
Modified: CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/test/test_sqlsyntax.py 2011-12-13 21:50:54 UTC (rev 8440)
+++ CalendarServer/branches/users/glyph/shared-pool-fixes/twext/enterprise/dal/test/test_sqlsyntax.py 2011-12-13 21:50:58 UTC (rev 8441)
@@ -1160,7 +1160,21 @@
self.assertEquals(curvars[1].type, FakeCXOracleModule.STRING)
+ def test_insertNoReturnOracle(self):
+ """
+ In addition to being able to execute insert statements with a Return
+ attribute, oracle also ought to be able to execute insert statements
+ with no Return at all.
+ """
+ # This statement should return nothing from .fetchall(), so...
+ self.factory.hasResults = False
+ i = Insert({self.schema.FOO.BAR: 40,
+ self.schema.FOO.BAZ: 50})
+ result = self.resultOf(i.on(self.createTransaction()))
+ self.assertEquals(result, [None])
+
+
class OracleConnectionTests(ConnectionPoolHelper, ExampleSchemaHelper,
OracleConnectionMethods, TestCase):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111213/293b857f/attachment-0001.html>
More information about the calendarserver-changes
mailing list