diff --git a/swh/storage/db.py b/swh/storage/db.py --- a/swh/storage/db.py +++ b/swh/storage/db.py @@ -604,50 +604,46 @@ ) """, ((id,) for id in releases)) - object_find_by_sha1_git_cols = ['sha1_git', 'type', 'id', 'object_id'] + object_find_by_sha1_git_cols = ['sha1_git', 'type'] def object_find_by_sha1_git(self, ids, cur=None): cur = self._cursor(cur) yield from execute_values_generator( cur, """ - WITH t (id) AS (VALUES %s), + WITH t (sha1_git) AS (VALUES %s), known_objects as (( select id as sha1_git, 'release'::object_type as type, - id, object_id from release r - where exists (select 1 from t where t.id = r.id) + where exists (select 1 from t where t.sha1_git = r.id) ) union all ( select id as sha1_git, 'revision'::object_type as type, - id, object_id from revision r - where exists (select 1 from t where t.id = r.id) + where exists (select 1 from t where t.sha1_git = r.id) ) union all ( select id as sha1_git, 'directory'::object_type as type, - id, object_id from directory d - where exists (select 1 from t where t.id = d.id) + where exists (select 1 from t where t.sha1_git = d.id) ) union all ( select sha1_git as sha1_git, 'content'::object_type as type, - sha1 as id, object_id from content c - where exists (select 1 from t where t.id = c.sha1_git) + where exists (select 1 from t where t.sha1_git = c.sha1_git) )) - select t.id as sha1_git, k.type, k.id, k.object_id + select t.sha1_git as sha1_git, k.type from t - left join known_objects k on t.id = k.sha1_git + left join known_objects k on t.sha1_git = k.sha1_git """, ((id,) for id in ids) ) diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -1075,8 +1075,6 @@ - sha1_git: the input id - type: the type of object found - - id: the id of the object found - - object_id: the numeric id of the object found. """ ret = {} @@ -1085,8 +1083,6 @@ ret[id_] = [{ 'sha1_git': id_, 'type': obj[0], - 'id': obj[1], - 'object_id': id_, } for obj in objs] return ret diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -1640,8 +1640,6 @@ - sha1_git: the input id - type: the type of object found - - id: the id of the object found - - object_id: the numeric id of the object found. """ ret = {id: [] for id in ids} diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -2873,7 +2873,6 @@ expected[data.cont['sha1_git']] = [{ 'sha1_git': data.cont['sha1_git'], 'type': 'content', - 'id': data.cont['sha1'], }] swh_storage.directory_add([data.dir]) @@ -2881,7 +2880,6 @@ expected[data.dir['id']] = [{ 'sha1_git': data.dir['id'], 'type': 'directory', - 'id': data.dir['id'], }] swh_storage.revision_add([data.revision]) @@ -2889,7 +2887,6 @@ expected[data.revision['id']] = [{ 'sha1_git': data.revision['id'], 'type': 'revision', - 'id': data.revision['id'], }] swh_storage.release_add([data.release]) @@ -2897,14 +2894,9 @@ expected[data.release['id']] = [{ 'sha1_git': data.release['id'], 'type': 'release', - 'id': data.release['id'], }] ret = swh_storage.object_find_by_sha1_git(sha1_gits) - for val in ret.values(): - for obj in val: - if 'object_id' in obj: - del obj['object_id'] assert expected == ret