[Calendar and Contacts Server] #469: incompatible with python-sqlparse 0.1.3 (Debian Testing)
#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: ---------------------------------+------------------------------------------ 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 ) -- Ticket URL: <http://trac.calendarserver.org/ticket/469> Calendar and Contacts Server </> HTTP/WebDAV/CalDAV Server
#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
#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: ---------------------------------+------------------------------------------ Comment(by glyph@…): Thanks for reporting this issue. The real problem here is that sqlparse doesn't have a very stable API at this point, so using the exactly required version is very important. With your patch, does the full test suite and CalDAVTester suite pass? -- Ticket URL: <http://trac.calendarserver.org/ticket/469#comment:2> Calendar and Contacts Server </> HTTP/WebDAV/CalDAV Server
#469: incompatible with python-sqlparse 0.1.3 (Debian Testing) ---------------------------------+------------------------------------------ Reporter: patrick.ohly@… | Owner: glyph@… Type: Enhancement | Status: assigned Priority: 5: Not set | Milestone: Component: Calendar Server | Severity: Other Keywords: | Radar: ---------------------------------+------------------------------------------ Changes (by glyph@…): * owner: wsanchez@… => glyph@… * status: new => assigned -- Ticket URL: <http://trac.calendarserver.org/ticket/469#comment:3> Calendar and Contacts Server </> HTTP/WebDAV/CalDAV Server
#469: incompatible with python-sqlparse 0.1.3 (Debian Testing) ---------------------------------+------------------------------------------ Reporter: patrick.ohly@… | Owner: glyph@… Type: Enhancement | Status: assigned Priority: 1: Blocker | Milestone: CalendarServer-4.x Component: Calendar Server | Severity: Other Keywords: | Radar: ---------------------------------+------------------------------------------ Changes (by wsanchez@…): * priority: 5: Not set => 1: Blocker * milestone: => CalendarServer-4.x -- Ticket URL: <http://trac.calendarserver.org/ticket/469#comment:4> Calendar and Contacts Server </> HTTP/WebDAV/CalDAV Server
participants (1)
-
Calendar and Contacts Server