From: Michael Tremer Date: Tue, 21 Jun 2022 15:35:23 +0000 (+0000) Subject: base: Integrate Data Objects better into SQL queries X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4704ee5e17e35332a1e72ee6acb79e51877d49a;p=pbs.git base: Integrate Data Objects better into SQL queries Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/base.py b/src/buildservice/base.py index cd979995..13160fdc 100644 --- a/src/buildservice/base.py +++ b/src/buildservice/base.py @@ -1,5 +1,7 @@ #!/usr/bin/python +import psycopg2.extensions + from .decorators import * class Object(object): @@ -89,3 +91,12 @@ class DataObject(Object): # Update cached attribute if res: self.data[key] = res[key] + + # SQL Integration + + def __conform__(self, proto): + if proto == psycopg2.extensions.ISQLQuote: + return self + + def getquoted(self): + return "(%d)" % self.id