Skip to content

Commit

Permalink
fix (Transforms): Don't substitute UTC_TIMESTAMP() values as parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuwd committed Nov 18, 2024
1 parent 26ffc26 commit cfc8e73
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/DIRAC/TransformationSystem/DB/TransformationDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,16 @@ def addTransformation(
"EventsPerTask": eventsPerTask,
}

# A list of parameters that we do not want to substitute as parameters, but directly
# into the statement
# I'm erring on the side of caution by using the _escapeString(body) version of the Body parameter,
# but for everything else it seems reasonably safe to use the parameterised query feature
subst = ", ".join(f"%({name})s" if name != "Body" else body for name in params)
unparameterised_columns = [
"Body",
"CreationDate",
"LastUpdate",
]
subst = ", ".join(f"%({name})s" if name not in unparameterised_columns else params[name] for name in params)

req = f"INSERT INTO Transformations ({', '.join(params)}) VALUES ({subst});"

Expand Down

0 comments on commit cfc8e73

Please sign in to comment.