UDT CQL encoding does not work for unicode values

Description

Using unicode as a value in a model with an UDT member will cause an exception.

Will raise the following (don't trust line numbers, some debug lines were added) :

Environment

linux / ubuntu LTS 14.04 / Python 2.7.6

Pull Requests

None

Activity

Show:
Greg Bestland
November 12, 2015, 11:50 PM
Michael Penick
November 2, 2015, 5:24 PM

+1 @ 5d03b8f

Adam Holmberg
October 29, 2015, 3:56 PM

Turns out this was not solved by (but that change is merged on the same PR).
https://github.com/datastax/python-driver/pull/432

The issue: field names from UDT meta are unicode. The encoder genexpr was implicitly converting all values to unicode for formatting. The default codec is ascii, so it bails when trying to decode non-ascii text. This fix just avoids implicit decoding by encoding the names as utf-8.

Right now the encoder tries to use the 'native' string type of the runtime (byte string for py2, unicode for py3). I would prefer to make the driver use unicode internally for constructing query strings, but the changes are too wide-ranging to take that on right now.

Adam Holmberg
June 22, 2015, 2:42 PM

This probably duplicates
https://github.com/datastax/python-driver/pull/344

Leaving open until analysis can confirm.

Fixed

Assignee

Unassigned

Reporter

Emmanuel BACHSCHMIDT

Fix versions

Reviewer

Michael Penick