[CalendarServer-changes] [7130] CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 7 19:02:54 PST 2011
Revision: 7130
http://trac.macosforge.org/projects/calendarserver/changeset/7130
Author: glyph at apple.com
Date: 2011-03-07 19:02:54 -0800 (Mon, 07 Mar 2011)
Log Message:
-----------
numeric paramstyle implementation in DAL
Modified Paths:
--------------
CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py
CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py
Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py 2011-03-08 03:02:42 UTC (rev 7129)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py 2011-03-08 03:02:54 UTC (rev 7130)
@@ -61,7 +61,7 @@
def __init__(self, dialect):
super(NumericPlaceholder, self).__init__(dialect)
- self._next = itertools.count().next
+ self._next = itertools.count(1).next
def placeholder(self):
@@ -99,7 +99,7 @@
_paramstyles = {
'pyformat': lambda dialect: FixedPlaceholder(dialect, "%s"),
- #'numeric': NumericPlaceholder
+ 'numeric': NumericPlaceholder
}
Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py 2011-03-08 03:02:42 UTC (rev 7129)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py 2011-03-08 03:02:54 UTC (rev 7130)
@@ -727,6 +727,29 @@
)
+ def test_numericParams(self):
+ """
+ An L{IAsyncTransaction} with the 'numeric' paramstyle attribute will
+ cause statements to be generated with parameters in the style of :1 :2
+ :3, as per the DB-API.
+ """
+ stmts = []
+ class FakeOracleTxn(object):
+ def execSQL(self, text, params, exc):
+ stmts.append((text, params))
+ dialect = ORACLE_DIALECT
+ paramstyle = 'numeric'
+ Select([self.schema.FOO.BAR],
+ From=self.schema.FOO,
+ Where=(self.schema.FOO.BAR == 7).And(
+ self.schema.FOO.BAZ == 9)
+ ).on(FakeOracleTxn())
+ self.assertEquals(
+ stmts, [("select BAR from FOO where BAR = :1 and BAZ = :2",
+ [7, 9])]
+ )
+
+
def test_nestedLogicalExpressions(self):
"""
Make sure that logical operator precedence inserts proper parenthesis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110307/e7ef2241/attachment.html>
More information about the calendarserver-changes
mailing list