apple / ccs-calendarserver

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

Unicode errors when using external PostgreSQL database #401

Open macosforgebot opened 8 years ago

macosforgebot commented 8 years ago

kmo@… originally submitted this as ticket:923


When testing the standard development build of CalendarServer-7.0 with the only config change that it connects to an external PostgreSQL database, an error message is logged from twext.enterprise.jobs.jobitem regarding a value that must not be of type unicode. Error message attached.

The problem seems to be located in the function calendarserver.tap.util.getDBPool where connectionFactory is instantiated from pgServiceFromConfig in case of an internal database and from DBAPIConnector for external databases. pgServiceFromConfig takes care of translating utf8 strings fetched from the database into a byte stream (type str), however DBAPIConnector seems to be missing that translation?

How to reproduce:

   <key>DBType</key>
    <string>postgres</string>
    <key>DatabaseConnection</key>
    <dict>
      <key>endpoint</key>
      <string>tcp:localhost</string>
      <key>database</key>
      <string>caldav</string>
      <key>user</key>
      <string>caldav</string>
      <key>password</key>
      <string>password</string>
    </dict>

This problem is probably related to the newly introduced use of the pg8000 module.

macosforgebot commented 8 years ago

kmo@… originally submitted this as attachment:error.txt:⁠ticket:923