Bug 113586 - Suppress UNSAFE STATEMENT warning

git-svn-id: svn://svn.office.custis.ru/3rdparty/viewvc.org/trunk@1626 6955db30-a419-402b-8a0d-67ecbb4d7f56
remotes/github/custis
vfilippov 2012-11-27 10:47:15 +00:00 committed by Vitaliy Filippov
parent 8492aa772e
commit 57e1ca8909
1 changed files with 12 additions and 7 deletions

View File

@ -18,6 +18,7 @@ import cgi
import vclib
import dbi
import warnings
## Current commits database schema version number.
##
@ -384,13 +385,17 @@ class CheckinDatabase:
cursor = self.db.cursor()
try:
# MySQL-specific INSERT-or-UPDATE with ID retrieval
cursor.execute(
'INSERT INTO '+commits_table+'('+','.join(i for i in props)+') VALUES ('+
', '.join('%s' for i in props)+') ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), '+
', '.join(i+'=VALUES('+i+')' for i in props),
tuple(props[i] for i in props)
)
with warnings.catch_warnings():
# MySQL-specific INSERT-or-UPDATE with ID retrieval
# MySQL 5.5+ will say it's unsafe, really it isn't because
# we specify values only for one unique key
warnings.filterwarnings('ignore', 'ON DUPLICATE KEY UPDATE.*is unsafe')
cursor.execute(
'INSERT INTO '+commits_table+'('+','.join(i for i in props)+') VALUES ('+
', '.join('%s' for i in props)+') ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id), '+
', '.join(i+'=VALUES('+i+')' for i in props),
tuple(props[i] for i in props)
)
commit_id = cursor.lastrowid
if self.index_content:
sphcur = self.sphinx.cursor()