[CalendarServer-changes] [6768] CalendarServer/branches/users/glyph/dal/txdav/base/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 19 12:57:51 PST 2011
Revision: 6768
http://trac.macosforge.org/projects/calendarserver/changeset/6768
Author: glyph at apple.com
Date: 2011-01-19 12:57:51 -0800 (Wed, 19 Jan 2011)
Log Message:
-----------
multi-unique identifiers
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py
CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_parseschema.py
Modified: CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py
===================================================================
--- CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py 2011-01-19 20:57:41 UTC (rev 6767)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlparser.py 2011-01-19 20:57:51 UTC (rev 6768)
@@ -166,9 +166,15 @@
elif constraintType.match(Keyword, 'UNIQUE'):
parens = iterSignificant(expect(self, cls=Parenthesis))
expect(parens, ttype=Punctuation, value="(")
- idname = expect(parens, cls=Identifier).get_name()
+ idorids = parens.next()
+ if isinstance(idorids, Identifier):
+ idnames = [idorids.get_name()]
+ elif isinstance(idorids, IdentifierList):
+ idnames = [x.get_name() for x in idorids.get_identifiers()]
+ else:
+ raise ViolatedExpectation("identifier or list", repr(idorids))
expect(parens, ttype=Punctuation, value=")")
- self.table.tableConstraint(Constraint.UNIQUE, [idname])
+ self.table.tableConstraint(Constraint.UNIQUE, idnames)
else:
raise ViolatedExpectation('PRIMARY or UNIQUE', constraintType)
return self.checkEnd(self.next())
Modified: CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_parseschema.py
===================================================================
--- CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_parseschema.py 2011-01-19 20:57:41 UTC (rev 6767)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_parseschema.py 2011-01-19 20:57:51 UTC (rev 6768)
@@ -109,4 +109,19 @@
self.assertEquals(list(table.uniques()), [set([column])])
+ def test_multiUnique(self):
+ """
+ A column with a UNIQUE constraint in SQL will result in the table
+ listing that column as a unique set.
+ """
+ s = Schema()
+ addSQLToSchema(
+ s,
+ "create table a (b integer, c integer, unique(b, c), unique(c));")
+ a = s.tableNamed('a')
+ b = a.columnNamed('b')
+ c = a.columnNamed('c')
+ self.assertEquals(list(a.uniques()),
+ [set([b, c]), set([c])])
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110119/2f329964/attachment-0001.html>
More information about the calendarserver-changes
mailing list