def get_package_instance(origin, package, version):
con = db_connect()
+ cur = con.cursor()
try:
- cur.execute("SELECT id FROM deb_package_instance"
+ cur.execute("SELECT deb_package_instance.id FROM deb_package_instance"
+ " JOIN deb_package ON (deb_package.id = deb_package_instance.deb_package_id)"
+ " JOIN deb_package_origin ON (deb_package_origin.id = deb_package_instance.deb_package_origin_id)"
+ " WHERE deb_package_origin.origin = '%s' AND deb_package.name = '%s' AND deb_package_instance.version = '%s'" % (origin, package, version))
+ except psycopg2.DatabaseError as e:
+ logger.debug("SELECT deb_package_instance.id FROM deb_package_instance"
" JOIN deb_package ON (deb_package.id = deb_package_instance.deb_package_id)"
" JOIN deb_package_origin ON (deb_package_origin.id = deb_package_instance.deb_package_origin_id)"
- " WHERE origin = '%s' AND package = '%s' AND version = '%s'" % (origin, package, version))
- except:
+ " WHERE deb_package_origin.origin = '%s' AND deb_package.name = '%s' AND deb_package_instance.version = '%s'" % (origin, package, version))
return False
- return cur.fetchone()[0]
-
+ if cur.fetchone():
+ return True