Handle unset CL on statements when printing/logging

This commit is contained in:
Tyler Hobbs
2014-05-21 16:31:29 -05:00
parent c07fc05868
commit a6a774b0fb

View File

@@ -346,7 +346,7 @@ class PreparedStatement(object):
return BoundStatement(self).bind(values)
def __str__(self):
consistency = ConsistencyLevel.value_to_name[self.consistency_level]
consistency = ConsistencyLevel.value_to_name.get(self.consistency_level, 'Not Set')
return (u'<PreparedStatement query="%s", consistency=%s>' %
(self.query_string, consistency))
__repr__ = __str__
@@ -484,7 +484,7 @@ class BoundStatement(Statement):
return None
def __str__(self):
consistency = ConsistencyLevel.value_to_name[self.consistency_level]
consistency = ConsistencyLevel.value_to_name.get(self.consistency_level, 'Not Set')
return (u'<BoundStatement query="%s", values=%s, consistency=%s>' %
(self.prepared_statement.query_string, self.raw_values, consistency))
__repr__ = __str__
@@ -622,7 +622,7 @@ class BatchStatement(Statement):
self.add(statement, parameters)
def __str__(self):
consistency = ConsistencyLevel.value_to_name[self.consistency_level]
consistency = ConsistencyLevel.value_to_name.get(self.consistency_level, 'Not Set')
return (u'<BatchStatement type=%s, statements=%d, consistency=%s>' %
(self.batch_type, len(self._statements_and_parameters), consistency))
__repr__ = __str__