[CalendarServer-dev] [Calendar and Contacts Server] #469: incompatible with python-sqlparse 0.1.3 (Debian Testing)
Calendar and Contacts Server
trac at macosforge.org
Tue Nov 15 10:15:20 PST 2011
#469: incompatible with python-sqlparse 0.1.3 (Debian Testing)
---------------------------------+------------------------------------------
Reporter: patrick.ohly@… | Owner: wsanchez@…
Type: Enhancement | Status: new
Priority: 5: Not set | Milestone:
Component: Calendar Server | Severity: Other
Keywords: | Radar:
---------------------------------+------------------------------------------
Old description:
> When starting the server with the system's python-sqlparse 0.1.3 instead
> of the version 0.1.2 that it would use as fallback, the server fails
> with:
>
> ...
> File
> "/home/pohly/src/CalendarServer/CalendarServer/twext/enterprise/dal/parseschema.py",
> line 232, in nextColumn
> return self.parseColumn(maybeIdent.value)
> File
> "/home/pohly/src/CalendarServer/CalendarServer/twext/enterprise/dal/parseschema.py",
> line 307, in parseColumn
> theType = SQLType(typeName.value.encode("utf-8"), typeLength)
> AttributeError: 'NoneType' object has no attribute 'encode'
>
> Adding some print statements showed that it fails for varchar entries:
>
> txdav/common/datastore/sql_schema/current.sql
> create table CALENDAR_HOME (
> RESOURCE_ID integer primary key default
> nextval('RESOURCE_ID_SEQ'),
> => OWNER_UID varchar(255) not null unique
> );
>
> In python-sqlparse, typeName.value was "varchar", same as the string
> representation of typeName itself. Based on that observation here's a
> crude patch which uses str(typeName) as default. Works for me, no idea
> whether it is the right fix...
>
> diff --git a/CalendarServer/twext/enterprise/dal/parseschema.py
> b/CalendarServer/twext/enterprise/dal/parseschema.py
> index 0978b5f..4e3fcb1 100644
> --- a/CalendarServer/twext/enterprise/dal/parseschema.py
> +++ b/CalendarServer/twext/enterprise/dal/parseschema.py
> @@ -304,7 +304,7 @@ class _ColumnParser(object):
> # something else
> typeLength = None
> self.pushback(maybeTypeArgs)
> - theType = SQLType(typeName.value.encode("utf-8"), typeLength)
> + theType = SQLType((typeName.value or
> str(typeName)).encode("utf-8"), typeLength)
> theColumn = self.table.addColumn(
> name=name.encode("utf-8"), type=theType
> )
New description:
When starting the server with the system's python-sqlparse 0.1.3 instead
of the version 0.1.2 that it would use as fallback, the server fails with:
{{{
File
"/home/pohly/src/CalendarServer/CalendarServer/twext/enterprise/dal/parseschema.py",
line 232, in nextColumn
return self.parseColumn(maybeIdent.value)
File
"/home/pohly/src/CalendarServer/CalendarServer/twext/enterprise/dal/parseschema.py",
line 307, in parseColumn
theType = SQLType(typeName.value.encode("utf-8"), typeLength)
AttributeError: 'NoneType' object has no attribute 'encode'
}}}
Adding some print statements showed that it fails for varchar entries:
{{{
txdav/common/datastore/sql_schema/current.sql
create table CALENDAR_HOME (
RESOURCE_ID integer primary key default
nextval('RESOURCE_ID_SEQ'),
=> OWNER_UID varchar(255) not null unique
);
}}}
In python-sqlparse, typeName.value was "varchar", same as the string
representation of typeName itself. Based on that observation here's a
crude patch which uses str(typeName) as default. Works for me, no idea
whether it is the right fix...
{{{
#!diff
diff --git a/CalendarServer/twext/enterprise/dal/parseschema.py
b/CalendarServer/twext/enterprise/dal/parseschema.py
index 0978b5f..4e3fcb1 100644
--- a/CalendarServer/twext/enterprise/dal/parseschema.py
+++ b/CalendarServer/twext/enterprise/dal/parseschema.py
@@ -304,7 +304,7 @@ class _ColumnParser(object):
# something else
typeLength = None
self.pushback(maybeTypeArgs)
- theType = SQLType(typeName.value.encode("utf-8"), typeLength)
+ theType = SQLType((typeName.value or
str(typeName)).encode("utf-8"), typeLength)
theColumn = self.table.addColumn(
name=name.encode("utf-8"), type=theType
)
}}}
--
Comment(by glyph@…):
Fixing formatting.
--
Ticket URL: <http://trac.calendarserver.org/ticket/469#comment:1>
Calendar and Contacts Server </>
HTTP/WebDAV/CalDAV Server
More information about the calendarserver-dev
mailing list