Improve message on bind type error.

Also updated integration/standard/test_types to work in python3
This commit is contained in:
Adam Holmberg
2015-01-22 09:24:10 -06:00
parent 61a0ec3160
commit a2ed58e72d
2 changed files with 5 additions and 5 deletions

View File

@@ -500,13 +500,13 @@ class BoundStatement(Statement):
try:
self.values.append(col_type.serialize(value, proto_version))
except (TypeError, struct.error):
except (TypeError, struct.error) as exc:
col_name = col_spec[2]
expected_type = col_type
actual_type = type(value)
message = ('Received an argument of invalid type for column "%s". '
'Expected: %s, Got: %s' % (col_name, expected_type, actual_type))
'Expected: %s, Got: %s; (%s)' % (col_name, expected_type, actual_type, exc))
raise TypeError(message)
return self

View File

@@ -700,10 +700,10 @@ class TypeTests(unittest.TestCase):
self.assertEquals((None, None, None, None), s.execute(read)[0].t)
# also test empty strings where compatible
s.execute(insert, [('', None, None, '')])
s.execute(insert, [('', None, None, b'')])
result = s.execute("SELECT * FROM mytable WHERE k=0")
self.assertEquals(('', None, None, ''), result[0].t)
self.assertEquals(('', None, None, ''), s.execute(read)[0].t)
self.assertEquals(('', None, None, b''), result[0].t)
self.assertEquals(('', None, None, b''), s.execute(read)[0].t)
c.shutdown()