[CalendarServer-changes] [7128] CalendarServer/branches/users/glyph/oracle/twext/enterprise
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 7 19:02:30 PST 2011
Revision: 7128
http://trac.macosforge.org/projects/calendarserver/changeset/7128
Author: glyph at apple.com
Date: 2011-03-07 19:02:30 -0800 (Mon, 07 Mar 2011)
Log Message:
-----------
render sequences differently depending on dialect
Modified Paths:
--------------
CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py
CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py
CalendarServer/branches/users/glyph/oracle/twext/enterprise/ienterprise.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:18 UTC (rev 7127)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/syntax.py 2011-03-08 03:02:30 UTC (rev 7128)
@@ -23,6 +23,7 @@
from twext.enterprise.ienterprise import POSTGRES_DIALECT
+from twext.enterprise.ienterprise import ORACLE_DIALECT
from twext.enterprise.dal.model import Schema, Table, Column, Sequence
@@ -303,7 +304,11 @@
"""
Convert to an SQL fragment.
"""
- return SQLFragment("nextval('%s')" % (self.model.name,))
+ if metadata.dialect == ORACLE_DIALECT:
+ fmt = "%s.nextval"
+ else:
+ fmt = "nextval('%s')"
+ return SQLFragment(fmt % (self.model.name,))
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:18 UTC (rev 7127)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/dal/test/test_sqlsyntax.py 2011-03-08 03:02:30 UTC (rev 7128)
@@ -28,7 +28,7 @@
from twext.enterprise.dal.syntax import FunctionInvocation
from twext.enterprise.dal.syntax import FixedPlaceholder
-from twext.enterprise.ienterprise import POSTGRES_DIALECT
+from twext.enterprise.ienterprise import POSTGRES_DIALECT, ORACLE_DIALECT
from twisted.trial.unittest import TestCase
@@ -694,6 +694,19 @@
SQLFragment("insert into BOZ (QUX) values (nextval('A_SEQ'))", []))
+ def test_nextSequenceValueOracle(self):
+ """
+ When a sequence is used as a value in an expression in the Oracle
+ dialect, it renders as the 'nextval' attribute of the appropriate
+ sequence.
+ """
+ self.assertEquals(
+ Insert({self.schema.BOZ.QUX:
+ self.schema.A_SEQ}).toSQL(
+ FixedPlaceholder(ORACLE_DIALECT, "?")),
+ SQLFragment("insert into BOZ (QUX) values (A_SEQ.nextval)", []))
+
+
def test_nestedLogicalExpressions(self):
"""
Make sure that logical operator precedence inserts proper parenthesis
Modified: CalendarServer/branches/users/glyph/oracle/twext/enterprise/ienterprise.py
===================================================================
--- CalendarServer/branches/users/glyph/oracle/twext/enterprise/ienterprise.py 2011-03-08 03:02:18 UTC (rev 7127)
+++ CalendarServer/branches/users/glyph/oracle/twext/enterprise/ienterprise.py 2011-03-08 03:02:30 UTC (rev 7128)
@@ -41,6 +41,7 @@
POSTGRES_DIALECT = 'postgres-dialect'
+ORACLE_DIALECT = 'oracle-dialect'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110307/5c2871b0/attachment-0001.html>
More information about the calendarserver-changes
mailing list