Skip to content

Commit 15c44d8

Browse files
committed
fix: Explicitly convert job IDs to numeric strings in JobDB
1 parent 94f19d7 commit 15c44d8

File tree

1 file changed

+3
-14
lines changed
  • src/DIRAC/WorkloadManagementSystem/DB

1 file changed

+3
-14
lines changed

src/DIRAC/WorkloadManagementSystem/DB/JobDB.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,7 @@ def getJobParameters(self, jobID, paramList=None):
106106
Returns a dictionary with the Job Parameters.
107107
If parameterList is empty - all the parameters are returned.
108108
"""
109-
110-
if isinstance(jobID, (str, int)):
111-
jobID = [jobID]
112-
113-
jobIDList = []
114-
for jID in jobID:
115-
ret = self._escapeString(str(jID))
116-
if not ret["OK"]:
117-
return ret
118-
jobIDList.append(ret["Value"])
119-
120-
# self.log.debug('JobDB.getParameters: Getting Parameters for jobs %s' % ','.join(jobIDList))
109+
jobIDList = [jobID] if isinstance(jobID, (str, int)) else jobID
121110

122111
resultDict = {}
123112
if paramList:
@@ -130,7 +119,7 @@ def getJobParameters(self, jobID, paramList=None):
130119
return ret
131120
paramNameList.append(ret["Value"])
132121
cmd = "SELECT JobID, Name, Value FROM JobParameters WHERE JobID IN ({}) AND Name IN ({})".format(
133-
",".join(jobIDList),
122+
",".join(str(int(j)) for j in jobIDList),
134123
",".join(paramNameList),
135124
)
136125
result = self._query(cmd)
@@ -560,7 +549,7 @@ def setJobAttributes(self, jobID, attrNames, attrValues, update=False, myDate=No
560549
if not attr:
561550
return S_ERROR("JobDB.setAttributes: Nothing to do")
562551

563-
cmd = f"UPDATE Jobs SET {', '.join(attr)} WHERE JobID in ( {', '.join(jIDList)} )"
552+
cmd = f"UPDATE Jobs SET {', '.join(attr)} WHERE JobID in ( {', '.join(str(int(j)) for j in jIDList)} )"
564553

565554
if myDate:
566555
cmd += f" AND LastUpdateTime < {myDate}"

0 commit comments

Comments
 (0)