Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/db.py
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | class Db(BaseDb): | ||||
def skipped_content_missing(self, contents, cur=None): | def skipped_content_missing(self, contents, cur=None): | ||||
if not contents: | if not contents: | ||||
return [] | return [] | ||||
cur = self._cursor(cur) | cur = self._cursor(cur) | ||||
query = """SELECT * FROM (VALUES %s) AS t (%s) | query = """SELECT * FROM (VALUES %s) AS t (%s) | ||||
WHERE not exists | WHERE not exists | ||||
(SELECT 1 FROM skipped_content s WHERE | (SELECT 1 FROM skipped_content s WHERE | ||||
s.sha1 is not distinct from t.sha1 and | s.sha1 is not distinct from t.sha1::sha1 and | ||||
s.sha1_git is not distinct from t.sha1_git and | s.sha1_git is not distinct from t.sha1_git::sha1 and | ||||
s.sha256 is not distinct from t.sha256);""" % \ | s.sha256 is not distinct from t.sha256::bytea);""" % \ | ||||
((', '.join('%s' for _ in contents)), | ((', '.join('%s' for _ in contents)), | ||||
', '.join(self.content_hash_keys)) | ', '.join(self.content_hash_keys)) | ||||
cur.execute(query, | cur.execute(query, | ||||
[tuple(cont[key] for key in self.content_hash_keys) | [tuple(cont[key] for key in self.content_hash_keys) | ||||
for cont in contents]) | for cont in contents]) | ||||
yield from cur | yield from cur | ||||
▲ Show 20 Lines • Show All 813 Lines • Show Last 20 Lines |