better syntax
This commit is contained in:
@@ -43,9 +43,8 @@ udt_by_keyspace = defaultdict(dict)
|
||||
|
||||
def format_log_context(msg, connection=None, keyspace=None):
|
||||
"""Format log message to add keyspace and connection context"""
|
||||
connection_info = connection
|
||||
if not connection_info:
|
||||
connection_info = 'DEFAULT_CONNECTION'
|
||||
connection_info = connection or 'DEFAULT_CONNECTION'
|
||||
|
||||
if keyspace:
|
||||
msg = '[Connection: {0}, Keyspace: {1}] {2}'.format(connection_info, keyspace, msg)
|
||||
else:
|
||||
|
||||
@@ -204,7 +204,7 @@ def _sync_table(model, connection=None):
|
||||
raw_cf_name = model._raw_column_family_name()
|
||||
|
||||
ks_name = model._get_keyspace()
|
||||
connection = connection if connection else model._get_connection()
|
||||
connection = connection or model._get_connection()
|
||||
|
||||
cluster = get_cluster(connection)
|
||||
|
||||
@@ -524,7 +524,7 @@ def _drop_table(model, connection=None):
|
||||
if not _allow_schema_modification():
|
||||
return
|
||||
|
||||
connection = connection if connection else model._get_connection()
|
||||
connection = connection or model._get_connection()
|
||||
|
||||
# don't try to delete non existant tables
|
||||
meta = get_cluster(connection).metadata
|
||||
|
||||
@@ -392,7 +392,7 @@ class AbstractQuerySet(object):
|
||||
if self._batch:
|
||||
return self._batch.add_query(statement)
|
||||
else:
|
||||
connection = self._connection if self._connection else self.model._get_connection()
|
||||
connection = self._connection or self.model._get_connection()
|
||||
result = _execute_statement(self.model, statement, self._consistency, self._timeout, connection=connection)
|
||||
if self._if_not_exists or self._if_exists or self._conditional:
|
||||
check_applied(result)
|
||||
@@ -1482,5 +1482,5 @@ def _execute_statement(model, statement, consistency_level, timeout, connection=
|
||||
parts = model._routing_key_from_values(key_values, conn.get_cluster(connection).protocol_version)
|
||||
s.routing_key = parts
|
||||
s.keyspace = model._get_keyspace()
|
||||
connection = connection if connection else model._get_connection()
|
||||
connection = connection or model._get_connection()
|
||||
return conn.execute(s, params, timeout=timeout, connection=connection)
|
||||
|
||||
Reference in New Issue
Block a user