Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9697382
D3193.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D3193.diff
View Options
diff --git a/swh/storage/db.py b/swh/storage/db.py
--- a/swh/storage/db.py
+++ b/swh/storage/db.py
@@ -6,7 +6,7 @@
import datetime
import random
import select
-from typing import Any, Dict, Optional, Tuple
+from typing import Any, Dict, List, Optional, Tuple
from swh.core.db import BaseDb
from swh.core.db.db_utils import stored_procedure, jsonize
@@ -667,7 +667,7 @@
return bool(cur.fetchone())
def origin_visit_get_latest(
- self, origin_id, allowed_statuses=None, require_snapshot=False, cur=None
+ self, origin_id: str, allowed_statuses=None, require_snapshot=False, cur=None
):
"""Retrieve the most recent origin_visit of the given origin,
with optional filters.
@@ -690,16 +690,15 @@
"INNER JOIN origin_visit_status ovs ",
"ON o.id = ovs.origin AND ov.visit = ovs.visit ",
]
-
query_parts.append("WHERE o.url = %s")
+ query_params: List[Any] = [origin_id]
if require_snapshot:
query_parts.append("AND ovs.snapshot is not null")
if allowed_statuses:
- query_parts.append(
- cur.mogrify("AND ovs.status IN %s", (tuple(allowed_statuses),)).decode()
- )
+ query_parts.append("AND ovs.status IN %s")
+ query_params.append(tuple(allowed_statuses))
query_parts.append(
"ORDER BY ov.date DESC, ov.visit DESC, ovs.date DESC LIMIT 1"
@@ -707,7 +706,7 @@
query = "\n".join(query_parts)
- cur.execute(query, (origin_id,))
+ cur.execute(query, tuple(query_params))
r = cur.fetchone()
if not r:
return None
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 17, 11:34 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3221985
Attached To
D3193: db: Use query_params instead of mogrify
Event Timeline
Log In to Comment