Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/db.py
Show First 20 Lines • Show All 745 Lines • ▼ Show 20 Lines | class Db(BaseDb): | ||||
person_get_cols = person_cols + ['id'] | person_get_cols = person_cols + ['id'] | ||||
def person_get(self, ids, cur=None): | def person_get(self, ids, cur=None): | ||||
"""Retrieve the persons identified by the list of ids. | """Retrieve the persons identified by the list of ids. | ||||
""" | """ | ||||
cur = self._cursor(cur) | cur = self._cursor(cur) | ||||
query = """SELECT %s | query = """SELECT %s FROM (VALUES %%s) as t(id) | ||||
FROM person | LEFT JOIN person ON t.id = person.id | ||||
WHERE id IN %%s""" % ', '.join(self.person_get_cols) | """ % ','.join('person.' + col for col in self.person_get_cols) | ||||
cur.execute(query, (tuple(ids),)) | yield from execute_values_generator( | ||||
yield from cur | cur, query, ((id,) for id in ids)) | ||||
release_add_cols = [ | release_add_cols = [ | ||||
'id', 'target', 'target_type', 'date', 'date_offset', | 'id', 'target', 'target_type', 'date', 'date_offset', | ||||
'date_neg_utc_offset', 'name', 'comment', 'synthetic', | 'date_neg_utc_offset', 'name', 'comment', 'synthetic', | ||||
'author_fullname', 'author_name', 'author_email', | 'author_fullname', 'author_name', 'author_email', | ||||
] | ] | ||||
release_get_cols = release_add_cols + ['author_id'] | release_get_cols = release_add_cols + ['author_id'] | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |