[CalendarServer-changes] [15153] twext/trunk/twext/enterprise/dal
source_changes at macosforge.org
source_changes at macosforge.org
Fri Sep 25 08:57:34 PDT 2015
Revision: 15153
http://trac.calendarserver.org//changeset/15153
Author: cdaboo at apple.com
Date: 2015-09-25 08:57:34 -0700 (Fri, 25 Sep 2015)
Log Message:
-----------
UID is a keyword in Oracle.
Modified Paths:
--------------
twext/trunk/twext/enterprise/dal/syntax.py
twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py
Modified: twext/trunk/twext/enterprise/dal/syntax.py
===================================================================
--- twext/trunk/twext/enterprise/dal/syntax.py 2015-09-25 01:56:49 UTC (rev 15152)
+++ twext/trunk/twext/enterprise/dal/syntax.py 2015-09-25 15:57:34 UTC (rev 15153)
@@ -885,7 +885,7 @@
return Join(self, type, otherTable, on)
-_KEYWORDS = [
+_KEYWORDS = frozenset([
# SQL keyword, but we have a column with this name
"access",
@@ -896,10 +896,14 @@
# not actually sure what this is; only experimentally determined that not
# quoting it causes an issue.
"size",
-]
+ # Oracle docs: UID returns an integer that uniquely identifies the session
+ # user (the user who logged on).
+ "uid",
+])
+
class ColumnSyntax(ExpressionSyntax):
"""
Syntactic convenience for L{Column}.
Modified: twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py 2015-09-25 01:56:49 UTC (rev 15152)
+++ twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py 2015-09-25 15:57:34 UTC (rev 15153)
@@ -2281,7 +2281,44 @@
)
+ def test_quoteUIDOracle(self):
+ """
+ Column names must be quoted in Oracle statements because some may
+ be reserved keywords (e.g., "UID").
+ """
+ UID_SCHAME = 'create table FOO ("BAR" integer, "UID" varchar(255));'
+ schema = SchemaSyntax(self.schemaFromString(UID_SCHAME))
+ self.assertEquals(
+ Insert(
+ {schema.FOO.BAR: 1, schema.FOO.UID: "test"},
+ ).toSQL(QueryGenerator(ORACLE_DIALECT, FixedPlaceholder("?"))),
+ SQLFragment(
+ "insert into FOO (BAR, \"UID\") values (?, ?)", [1, "test"]
+ )
+ )
+ self.assertEquals(
+ Update(
+ {schema.FOO.BAR: 1, schema.FOO.UID: "test"},
+ Where=(schema.FOO.BAR == 2),
+ ).toSQL(QueryGenerator(ORACLE_DIALECT, FixedPlaceholder("?"))),
+ SQLFragment(
+ "update FOO set BAR = ?, \"UID\" = ? where BAR = ?", [1, "test", 2]
+ )
+ )
+ self.assertEquals(
+ Select(
+ [schema.FOO.BAR, schema.FOO.UID],
+ From=schema.FOO,
+ Where=(schema.FOO.UID == "test"),
+ ).toSQL(QueryGenerator(ORACLE_DIALECT, FixedPlaceholder("?"))),
+ SQLFragment(
+ "select BAR, \"UID\" from FOO where \"UID\" = ?", ["test"]
+ )
+ )
+
+
+
class OracleConnectionMethods(object):
def test_rewriteOracleNULLs_Insert(self):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150925/aaed4acf/attachment-0001.html>
More information about the calendarserver-changes
mailing list