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) return BoundStatement(self).bind(values)
def __str__(self): 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>' % return (u'<PreparedStatement query="%s", consistency=%s>' %
(self.query_string, consistency)) (self.query_string, consistency))
__repr__ = __str__ __repr__ = __str__
@@ -484,7 +484,7 @@ class BoundStatement(Statement):
return None return None
def __str__(self): 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>' % return (u'<BoundStatement query="%s", values=%s, consistency=%s>' %
(self.prepared_statement.query_string, self.raw_values, consistency)) (self.prepared_statement.query_string, self.raw_values, consistency))
__repr__ = __str__ __repr__ = __str__
@@ -622,7 +622,7 @@ class BatchStatement(Statement):
self.add(statement, parameters) self.add(statement, parameters)
def __str__(self): 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>' % return (u'<BatchStatement type=%s, statements=%d, consistency=%s>' %
(self.batch_type, len(self._statements_and_parameters), consistency)) (self.batch_type, len(self._statements_and_parameters), consistency))
__repr__ = __str__ __repr__ = __str__