apple / ccs-calendarserver

The Calendar and Contacts Server.
https://www.calendarserver.org
Apache License 2.0
486 stars 136 forks source link

incompatible with python-sqlparse 0.1.4 #375

Closed macosforgebot closed 11 years ago

macosforgebot commented 11 years ago

fred@… originally submitted this as ticket:759


Parsing the current.sql (trunk-r10029) fails with using python-sqlparse (0.1.4-1) from debian (sid/testing).

This problem relates to #⁠469 and #⁠486 as well. It seems those bugs were solved in 0.1.4. The new current error is :

  File "twext/enterprise/dal/parseschema.py", line 496, in expectSingle
    raise ViolatedExpectation(ttype, '%s:%r' % (nextval.ttype, nextval))
twext.enterprise.dal.parseschema.ViolatedExpectation: Expected Token.Keyword got None:<Function 'key(HO...' at 0x36abc80>

The reason is that sqlparse mistakes primary key(HOSTNAME, PORT) for a keyword + function instead of 2 keywords.

By separarating the () from the keyword it gets parsed correctly. primary key (HOSTNAME, PORT)

This simple change makes the server start but there are more problems in current.sql all fixed in the attached patch and I also adapted the testsuite twext/enterprise/dal/test/test_parseschema.py

With the attached patch the whole testsuite runs :

trial twext/enterprise/dal/test/
twext.enterprise.dal.test.test_parseschema
  ParsingExampleTests
    test_cascade ...                                                       [OK]
    ... [cut out for clarity] ...
    test_rewriteOracleNULLs_Insert ...                                     [OK]

-------------------------------------------------------------------------------
Ran 124 tests in 5.784s

PASSED (successes=124)

The included patch is for trunk, backporting it for distributions that are using newer python-sqlparse should be easy.

The upgrade schemas txdav/common/datastore/sql_schema/upgrades/ nor txdav/common/datastore/sql_schema/current-oracle-dialect.sql were tested.

Extensive testing was not made, but the server starts.

macosforgebot commented 11 years ago

fred@… originally submitted this as attachment:python-sqlparse-0.1.4.patch:⁠ticket:759


Patch enabling the use of Debian python-sqlparse (0.1.4-1)

macosforgebot commented 11 years ago

@wsanchez originally submitted this as comment:1:⁠ticket:759


Weird that sqlparse regressed in this way. Thanks for the patch.

Applied in r10038.

macosforgebot commented 11 years ago

@wsanchez originally submitted this as comment:5:⁠ticket:759


Do we run into the problems noted in #⁠469 and #⁠486 when using sqlparse-0.1.4? (Those bugs refer to 0.1.3.)

macosforgebot commented 11 years ago

@wsanchez originally submitted this as comment:6:⁠ticket:759


See also #⁠759.

macosforgebot commented 11 years ago

@wsanchez originally submitted this as comment:7:⁠ticket:759


Fixed in r10038