[CalendarServer-changes] [6764] CalendarServer/branches/users/glyph/dal/txdav/base/datastore

source_changes at macosforge.org source_changes at macosforge.org
Wed Jan 19 12:57:09 PST 2011


Revision: 6764
          http://trac.macosforge.org/projects/calendarserver/changeset/6764
Author:   glyph at apple.com
Date:     2011-01-19 12:57:09 -0800 (Wed, 19 Jan 2011)
Log Message:
-----------
sequence schema association test (failing)

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlmodel.py
    CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_parseschema.py

Modified: CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlmodel.py
===================================================================
--- CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlmodel.py	2011-01-19 20:56:59 UTC (rev 6763)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/sqlmodel.py	2011-01-19 20:57:09 UTC (rev 6764)
@@ -1,3 +1,4 @@
+# -*- test-case-name: txdav.base.datastore.test.test_parseschema -*-
 ##
 # Copyright (c) 2010 Apple Inc. All rights reserved.
 #
@@ -159,6 +160,10 @@
         self.referringColumns = []
 
 
+    def __repr__(self):
+        return '<Sequence %r>' % (self.name,)
+
+
 class Schema(object):
     """
     A schema containing tables, indexes, and sequences.

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:56:59 UTC (rev 6763)
+++ CalendarServer/branches/users/glyph/dal/txdav/base/datastore/test/test_parseschema.py	2011-01-19 20:57:09 UTC (rev 6764)
@@ -50,3 +50,29 @@
         self.assertEquals(s.sequences[0].name, "myseq")
 
 
+    def test_sequenceColumn(self):
+        """
+        Parsing a 'create sequence' statement adds a L{Sequence} to the
+        L{Schema}, and then a table that contains a column which uses the SQL
+        C{nextval()} function to retrieve its default value from that sequence,
+        will cause the L{Column} object to refer to the L{Sequence} and vice
+        versa.
+        """
+        s = Schema()
+        addSQLToSchema(
+            s,
+            """
+            create sequence thingy;
+            create table thetable (
+                thecolumn integer default nextval('thingy')
+            );
+            """
+        )
+        self.assertEquals(len(s.sequences), 1)
+        self.assertEquals(s.sequences[0].name, "thingy")
+        self.assertEquals(s.tables[0].columns[0].default, s.sequences[0])
+        self.assertEquals(s.sequences[0].referringColumns,
+                          [s.tables[0].columns[0]])
+
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110119/b36864d1/attachment-0001.html>


More information about the calendarserver-changes mailing list