rename option
This commit is contained in:
parent
0449aa4829
commit
6aaa6b3248
5 changed files with 13 additions and 13 deletions
|
|
@ -5421,13 +5421,13 @@ def _singleValue(query, values=None, strict=True):
|
|||
return None
|
||||
|
||||
|
||||
def _dml(operation, values, log=True):
|
||||
def _dml(operation, values, log_errors=True):
|
||||
"""Run an insert, update, or delete. Return number of rows affected
|
||||
If log is False, errors will not be logged. It makes sense only for
|
||||
queries which are expected to fail (LOCK NOWAIT)
|
||||
"""
|
||||
c = context.cnx.cursor()
|
||||
c.execute(operation, values, log=log)
|
||||
c.execute(operation, values, log_errors=log_errors)
|
||||
ret = c.rowcount
|
||||
logger.debug("Operation affected %s row(s)", ret)
|
||||
c.close()
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class CursorWrapper:
|
|||
params[i] = tuple(item)
|
||||
return sql, params
|
||||
|
||||
def execute(self, operation, parameters=(), log=True):
|
||||
def execute(self, operation, parameters=(), log_errors=True):
|
||||
debug = self.logger.isEnabledFor(logging.DEBUG)
|
||||
operation, parameters = self.preformat(operation, parameters)
|
||||
if debug:
|
||||
|
|
@ -141,7 +141,7 @@ class CursorWrapper:
|
|||
try:
|
||||
ret = self.cursor.execute(operation, parameters)
|
||||
except Exception:
|
||||
if log:
|
||||
if log_errors:
|
||||
self.logger.error('Query failed. Query was: %s', self.quote(operation, parameters))
|
||||
raise
|
||||
if debug:
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ def handle_db_msgs(urls, CONFIG):
|
|||
# we're running in postCommit, so we need to handle new transaction
|
||||
c.execute('BEGIN')
|
||||
try:
|
||||
c.execute('LOCK TABLE proton_queue IN ACCESS EXCLUSIVE MODE NOWAIT', log=False)
|
||||
c.execute('LOCK TABLE proton_queue IN ACCESS EXCLUSIVE MODE NOWAIT', log_errors=False)
|
||||
except psycopg2.OperationalError:
|
||||
LOG.debug('skipping db queue due to lock')
|
||||
return
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class TestInsertProcessor(unittest.TestCase):
|
|||
proc.execute()
|
||||
cursor.execute.assert_called_once_with(
|
||||
'INSERT INTO sometable (foo) VALUES (%(foo)s)',
|
||||
{'foo': 'bar'}, log=True)
|
||||
{'foo': 'bar'}, log_errors=True)
|
||||
|
||||
@mock.patch('kojihub.context')
|
||||
def test_make_create(self, context):
|
||||
|
|
@ -115,7 +115,7 @@ class TestBulkInsertProcessor(unittest.TestCase):
|
|||
cursor.execute.assert_called_once_with(
|
||||
'INSERT INTO sometable (foo) VALUES (%(foo0)s)',
|
||||
{'foo0': 'bar'},
|
||||
log=True
|
||||
log_errors=True
|
||||
)
|
||||
|
||||
cursor.reset_mock()
|
||||
|
|
@ -125,7 +125,7 @@ class TestBulkInsertProcessor(unittest.TestCase):
|
|||
cursor.execute.assert_called_once_with(
|
||||
'INSERT INTO sometable (foo) VALUES (%(foo0)s)',
|
||||
{'foo0': 'bar'},
|
||||
log=True
|
||||
log_errors=True
|
||||
)
|
||||
|
||||
@mock.patch('kojihub.context')
|
||||
|
|
@ -140,7 +140,7 @@ class TestBulkInsertProcessor(unittest.TestCase):
|
|||
cursor.execute.assert_called_once_with(
|
||||
'INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s), (%(foo2)s)',
|
||||
{'foo0': 'bar1', 'foo1': 'bar2', 'foo2': 'bar3'},
|
||||
log=True
|
||||
log_errors=True
|
||||
)
|
||||
|
||||
def test_missing_values(self):
|
||||
|
|
@ -180,10 +180,10 @@ class TestBulkInsertProcessor(unittest.TestCase):
|
|||
self.assertEqual(len(calls), 2)
|
||||
self.assertEqual(calls[0],
|
||||
mock.call('INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s)',
|
||||
{'foo0': 'bar1', 'foo1': 'bar2'}, log=True))
|
||||
{'foo0': 'bar1', 'foo1': 'bar2'}, log_errors=True))
|
||||
self.assertEqual(calls[1],
|
||||
mock.call('INSERT INTO sometable (foo) VALUES (%(foo0)s)',
|
||||
{'foo0': 'bar3'}, log=True))
|
||||
{'foo0': 'bar3'}, log_errors=True))
|
||||
|
||||
@mock.patch('kojihub.context')
|
||||
def test_no_batch_execution(self, context):
|
||||
|
|
@ -200,5 +200,5 @@ class TestBulkInsertProcessor(unittest.TestCase):
|
|||
self.assertEqual(
|
||||
calls[0],
|
||||
mock.call('INSERT INTO sometable (foo) VALUES (%(foo0)s), (%(foo1)s), (%(foo2)s)',
|
||||
{'foo0': 'bar1', 'foo1': 'bar2', 'foo2': 'bar3'}, log=True)
|
||||
{'foo0': 'bar1', 'foo1': 'bar2', 'foo2': 'bar3'}, log_errors=True)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -30,5 +30,5 @@ class TestUpdateProcessor(unittest.TestCase):
|
|||
cursor.execute.assert_called_once_with(
|
||||
'UPDATE sometable SET foo = %(data.foo)s',
|
||||
{'data.foo': 'bar'},
|
||||
log=True,
|
||||
log_errors=True,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue