Improve message on bind type error.
Also updated integration/standard/test_types to work in python3
This commit is contained in:
@@ -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
|
||||
|
@@ -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()
|
||||
|
||||
|
Reference in New Issue
Block a user