Skip to content

Commit 901b4cc

Browse files
committed
Fix new queries to find config doc (OCECDR-4441)
1 parent 095add4 commit 901b4cc

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

tasks/file_sweeper_task.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -968,28 +968,31 @@ def loadConfigFile(fileName):
968968
JOIN doc_type t
969969
ON t.id = v.doc_type
970970
WHERE t.name = 'SweepSpecifications'
971-
AND v.val_status = 'V'""")
971+
AND v.val_status = 'V'
972+
GROUP BY v.id""")
972973
rows = cursor.fetchall()
973974
if len(rows) > 1:
974975
fatalError("More than on SweepSpecifications document found")
975976
elif len(rows) == 1:
976-
cursor.execute("""\
977-
SELECT xml
978-
FROM doc_version
979-
WHERE id = ?
980-
AND num = ?""", tuple(row))
981-
xml = cursor.fetchone()[0]
977+
doc_id, version = rows[0]
978+
query = cdrdb.Query("doc_version", "xml")
979+
query.where(query.Condition("id", doc_id))
980+
query.where(query.Condition("num", version))
981+
row = query.execute(cursor).fetchone()
982982
try:
983-
dom = xml.dom.minidom.parseString(xml.encode("utf-8"))
983+
dom = xml.dom.minidom.parseString(row[0].encode("utf-8"))
984+
args = doc_id, version
985+
log("loaded config from CDR{:d} version {:d}".format(*args))
984986
except Exception as e:
985987
msg = "Failure parsing config document CDR{:d} version {:d}: {}"
986-
args = row[0], row[1], e
988+
args = doc_id, version, e
987989
fatalError(msg.format(*args))
988990

989991
# Otherwise, parse file from disk (temporary fallback)
990992
else:
991993
try:
992994
dom = xml.dom.minidom.parse(fileName)
995+
log("loaded config from {}".format(fileName))
993996
except Exception, info:
994997
fatalError("Error loading config file %s: %s" % (fileName, info))
995998

0 commit comments

Comments
 (0)