[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] dak/process_policy.py: escape '_' in string passed to SQL LIKE operator later



---
 dak/process_policy.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/dak/process_policy.py b/dak/process_policy.py
index 77bc448..8103fd0 100755
--- a/dak/process_policy.py
+++ b/dak/process_policy.py
@@ -68,6 +68,10 @@ def do_comments(dir, srcqueue, opref, npref, line, fn, transaction):
         else:
             changes_prefix = changes_prefix + '.changes'
 
+        # We need to escape "_" as we use it with the LIKE operator (via the
+        # SQLA startwith) later.
+        changes_prefix = changes_prefix.replace("_", r"\_")
+
         uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=srcqueue) \
             .join(PolicyQueueUpload.changes).filter(DBChange.changesname.startswith(changes_prefix)) \
             .order_by(PolicyQueueUpload.source_id)
-- 
1.7.2.5


Reply to: