[CalendarServer-changes] [8805] CalendarServer/branches/users/glyph/case-insensitive-uid

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 29 11:17:22 PST 2012


Revision: 8805
          http://trac.macosforge.org/projects/calendarserver/changeset/8805
Author:   glyph at apple.com
Date:     2012-02-29 11:17:20 -0800 (Wed, 29 Feb 2012)
Log Message:
-----------
What we're interested in is case-folding, not lower-casing, so let's call it that.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py
    CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/syntax.py
    CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py
    CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py
    CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/case-insensitive-uid/

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py	2012-02-29 18:16:44 UTC (rev 8804)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/calendarserver/tools/dbinspect.py	2012-02-29 19:17:20 UTC (rev 8805)
@@ -43,7 +43,7 @@
 import os
 import sys
 import traceback
-from twext.enterprise.dal.syntax import Lower
+from twext.enterprise.dal.syntax import CaseFold
 
 def usage(e=None):
     if e:
@@ -521,7 +521,7 @@
                 cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
                     cb.BIND_MODE == _BIND_MODE_OWN)).join(
                 co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
-            Where=(ch.OWNER_UID == Lower(Parameter("UID"))),
+            Where=(ch.OWNER_UID == CaseFold(Parameter("UID"))),
         ).on(txn, **{"UID": uid}))
         returnValue(tuple(rows))
 
@@ -572,7 +572,7 @@
                 cb, type="inner", on=(ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
                     cb.BIND_MODE == _BIND_MODE_OWN)).join(
                 co, type="inner", on=(cb.CALENDAR_RESOURCE_ID == co.CALENDAR_RESOURCE_ID)),
-            Where=((ch.OWNER_UID == Lower(Parameter("UID"))).And(cb.CALENDAR_RESOURCE_NAME == Parameter("NAME"))),
+            Where=((ch.OWNER_UID == CaseFold(Parameter("UID"))).And(cb.CALENDAR_RESOURCE_NAME == Parameter("NAME"))),
         ).on(txn, **{"UID": uid, "NAME": name}))
         returnValue(tuple(rows))
 

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/syntax.py	2012-02-29 18:16:44 UTC (rev 8804)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/twext/enterprise/dal/syntax.py	2012-02-29 19:17:20 UTC (rev 8805)
@@ -425,8 +425,13 @@
 Upper = Function("upper")
 Lower = Function("lower")
 
+# Use a specific value here for "the convention for case-insensitive values in
+# the database" so we don't need to keep remembering whether it's upper or
+# lowercase.
+CaseFold = Lower
 
 
+
 class SchemaSyntax(Syntax):
     """
     Syntactic convenience for L{Schema}.

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py	2012-02-29 18:16:44 UTC (rev 8804)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql.py	2012-02-29 19:17:20 UTC (rev 8805)
@@ -71,7 +71,7 @@
 from twext.enterprise.dal.syntax import SavepointAction
 from twext.enterprise.dal.syntax import Select
 from twext.enterprise.dal.syntax import Update
-from twext.enterprise.dal.syntax import Lower
+from twext.enterprise.dal.syntax import CaseFold
 
 from txdav.base.propertystore.base import PropertyName
 from txdav.base.propertystore.none import PropertyStore as NonePropertyStore
@@ -843,7 +843,7 @@
     def _resourceIDFromOwnerQuery(cls): #@NoSelf
         home = cls._homeSchema
         return Select([home.RESOURCE_ID],
-                      From=home, Where=home.OWNER_UID == Lower(Parameter("ownerUID")))
+                      From=home, Where=home.OWNER_UID == CaseFold(Parameter("ownerUID")))
 
     @classproperty
     def _ownerFromFromResourceID(cls): #@NoSelf
@@ -910,7 +910,7 @@
             try:
                 resourceid = (yield Insert(
                     {
-                        cls._homeSchema.OWNER_UID: Lower(uid),
+                        cls._homeSchema.OWNER_UID: CaseFold(uid),
                         cls._homeSchema.DATAVERSION: cls._dataVersionValue,
                     },
                     Return=cls._homeSchema.RESOURCE_ID).on(txn))[0][0]
@@ -3009,11 +3009,11 @@
 
     _resourceIDFromUIDQuery = Select(
         [_homeSchema.RESOURCE_ID], From=_homeSchema,
-        Where=_homeSchema.OWNER_UID == Lower(Parameter("uid")))
+        Where=_homeSchema.OWNER_UID == CaseFold(Parameter("uid")))
 
 
     _provisionNewNotificationsQuery = Insert(
-        {_homeSchema.OWNER_UID: Lower(Parameter("uid"))},
+        {_homeSchema.OWNER_UID: CaseFold(Parameter("uid"))},
         Return=_homeSchema.RESOURCE_ID
     )
 

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py	2012-02-29 18:16:44 UTC (rev 8804)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/sql_legacy.py	2012-02-29 19:17:20 UTC (rev 8805)
@@ -56,7 +56,7 @@
 
 
 from pycalendar.duration import PyCalendarDuration
-from twext.enterprise.dal.syntax import Lower
+from twext.enterprise.dal.syntax import CaseFold
 
 log = Logger()
 
@@ -222,7 +222,7 @@
         home = cls._homeSchema
         return cls._allColumnsQuery(
             (inv.RESOURCE_ID == Parameter("resourceID"))
-            .And(home.OWNER_UID == Lower(Parameter("principalUID")))
+            .And(home.OWNER_UID == CaseFold(Parameter("principalUID")))
         )
 
 

Modified: CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py
===================================================================
--- CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py	2012-02-29 18:16:44 UTC (rev 8804)
+++ CalendarServer/branches/users/glyph/case-insensitive-uid/txdav/common/datastore/upgrade/sql/upgrade.py	2012-02-29 19:17:20 UTC (rev 8805)
@@ -31,7 +31,7 @@
 from twisted.python.reflect import namedObject
 from txdav.common.datastore.sql_tables import schema
 from twext.enterprise.dal.syntax import Select
-from twext.enterprise.dal.syntax import Lower
+from twext.enterprise.dal.syntax import CaseFold
 from twext.enterprise.dal.syntax import Update
 from twext.enterprise.dal.syntax import Max
 
@@ -358,7 +358,7 @@
         right = home.alias()
         qry = Select(
             [left.OWNER_UID, right.OWNER_UID], From=left.join(right),
-            Where=(Lower(left.OWNER_UID) == Lower(right.OWNER_UID))
+            Where=(CaseFold(left.OWNER_UID) == CaseFold(right.OWNER_UID))
             # Use > rather than != so that each duplicate only shows up
             # once.
             .And(left.OWNER_UID > right.OWNER_UID)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120229/86e5465c/attachment-0001.html>


More information about the calendarserver-changes mailing list