Skip to content

Commit

Permalink
dmwm/crabserver dmwm#6830 dmwm#6880 - raise before wrong types are in…
Browse files Browse the repository at this point in the history
…serted to oracle DB
  • Loading branch information
mapellidario committed Dec 9, 2021
1 parent f528649 commit 23fef9b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/python/WMCore/REST/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,13 @@ def execute(self, sql, *binds, **kwbinds):
trace = request.db["handle"]["trace"]
request.db["last_bind"] = (binds, kwbinds)
trace and cherrypy.log("%s execute: %s %s" % (trace, binds, kwbinds))
# Debug crabserver https://github.com/dmwm/CRABServer/issues/6880 - start
for k, v in viewitems(kwbinds):
if not isinstance(v, (int, str, type(None))):
cherrypy.log("%s execute debug. field: %s, type: %s, content: %s" %(trace, k, type(v), v))
import datetime
raise Exception("%s Unexpected variable type about to be inserted into the DB. field: %s, type: %s, content: %s" % (datetime.datetime.now(), k, type(v), v))
# Debug crabserver https://github.com/dmwm/CRABServer/issues/6880 - end
if request.db['type'].__name__ == 'MySQLdb':
return c, c.execute(sql, kwbinds)
return c, c.execute(None, *binds, **kwbinds)
Expand All @@ -2111,6 +2118,14 @@ def executemany(self, sql, *binds, **kwbinds):
trace = request.db["handle"]["trace"]
request.db["last_bind"] = (binds, kwbinds)
trace and cherrypy.log("%s executemany: %s %s" % (trace, binds, kwbinds))
# Debug crabserver https://github.com/dmwm/CRABServer/issues/6880 - start
for q in binds[0]:
for k, v in viewitems(q):
if not isinstance(v, (int, str, type(None))):
cherrypy.log("%s executemany debug: field: %s, type: %s, content: %s" %(trace, k, type(v), v))
import datetime
raise Exception("%s Unexpected variable type about to be inserted into the DB. field: %s, type %s, content %s" % (datetime.datetime.now(), k, type(v), v))
# Debug crabserver https://github.com/dmwm/CRABServer/issues/6880 - end
if request.db['type'].__name__ == 'MySQLdb':
return c, c.executemany(sql, binds[0])
return c, c.executemany(None, *binds, **kwbinds)
Expand Down

0 comments on commit 23fef9b

Please sign in to comment.