change(python): use a transaction query in get_pkg_or_base

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2022-01-16 02:00:41 -08:00
parent 9441f4f904
commit 64069b9b5d
No known key found for this signature in database
GPG key ID: F7E46DED420788F3

View file

@ -103,11 +103,13 @@ def get_pkg_or_base(
if provider: if provider:
raise HTTPException(status_code=HTTPStatus.NOT_FOUND) raise HTTPException(status_code=HTTPStatus.NOT_FOUND)
with db.begin():
instance = db.query(cls).filter(cls.Name == name).first() instance = db.query(cls).filter(cls.Name == name).first()
if not instance: if not instance:
raise HTTPException(status_code=HTTPStatus.NOT_FOUND) raise HTTPException(status_code=HTTPStatus.NOT_FOUND)
return db.refresh(instance) return instance
def get_pkgbase_comment(pkgbase: models.PackageBase, id: int) \ def get_pkgbase_comment(pkgbase: models.PackageBase, id: int) \