[CalendarServer-changes] [7857] CalendarServer/trunk/txdav/common/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Mon Aug 8 12:27:44 PDT 2011
Revision: 7857
http://trac.macosforge.org/projects/calendarserver/changeset/7857
Author: glyph at apple.com
Date: 2011-08-08 12:27:42 -0700 (Mon, 08 Aug 2011)
Log Message:
-----------
add schemaRows to translated schema, plus simple test for CALENDARSERVER_VERSION row
Modified Paths:
--------------
CalendarServer/trunk/txdav/common/datastore/sql_tables.py
CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py
Modified: CalendarServer/trunk/txdav/common/datastore/sql_tables.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_tables.py 2011-08-06 17:54:59 UTC (rev 7856)
+++ CalendarServer/trunk/txdav/common/datastore/sql_tables.py 2011-08-08 19:27:42 UTC (rev 7857)
@@ -1,4 +1,4 @@
-# -*- test-case-name: txdav.caldav.datastore.test.test_sql -*-
+# -*- test-case-name: txdav.common.datastore.test.test_sql_tables -*-
##
# Copyright (c) 2010 Apple Inc. All rights reserved.
#
@@ -23,6 +23,9 @@
from twext.enterprise.dal.syntax import SchemaSyntax
from twext.enterprise.dal.model import NO_DEFAULT
from twext.enterprise.dal.model import Sequence, ProcedureCall
+from twext.enterprise.dal.syntax import FixedPlaceholder
+from twext.enterprise.ienterprise import ORACLE_DIALECT
+from twext.enterprise.dal.syntax import Insert
from twext.enterprise.dal.parseschema import schemaFromPath
@@ -266,6 +269,26 @@
out.write('\n);\n\n')
+ fakeMeta = FixedPlaceholder(ORACLE_DIALECT, '%s')
+ def quoted(x):
+ if isinstance(x, (str, unicode)):
+ return ''.join(["'", x.replace("'", "''"), "'"])
+ else:
+ return str(x)
+
+ for row in table.model.schemaRows:
+ cmap = dict(
+ [(getattr(table, cmodel.name), val)
+ for (cmodel, val) in row.items()]
+ )
+ fragment = Insert(cmap).toSQL(fakeMeta)
+ out.write(
+ fragment.text % tuple([quoted(param)
+ for param in fragment.parameters]),
+ )
+ out.write(";\n")
+
+
for (num, index) in enumerate(schema.model.indexes):
# Index names combine and repeat multiple table names and column names,
# so several of them conflict once oracle's length limit is applied.
Modified: CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py 2011-08-06 17:54:59 UTC (rev 7856)
+++ CalendarServer/trunk/txdav/common/datastore/test/test_sql_tables.py 2011-08-08 19:27:42 UTC (rev 7857)
@@ -50,4 +50,15 @@
_translateSchema(StringIO())
+ def test_schemaTranslationIncludesVersion(self):
+ """
+ _translateSchema includes 'insert' rows too.
+ """
+ io = StringIO()
+ _translateSchema(io)
+ self.assertIn("insert into CALENDARSERVER (NAME, VALUE) "
+ "values ('VERSION', '3');",
+ io.getvalue())
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110808/da736379/attachment.html>
More information about the calendarserver-changes
mailing list