X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPostgreSQL.py;h=076a8643dd6e3d7ea1e8e2360171e13244734b0c;hb=9d42db6d25662e18156bda85c5416f38cfa5276d;hp=101cfe63d4546f796fadcef2ecadb502cbee1b83;hpb=f936d674e4489551a0cbc441ad80e32316db7207;p=plcapi.git diff --git a/PLC/PostgreSQL.py b/PLC/PostgreSQL.py index 101cfe6..076a864 100644 --- a/PLC/PostgreSQL.py +++ b/PLC/PostgreSQL.py @@ -89,6 +89,12 @@ class PostgreSQL: self.connection.close() self.connection = None + # join insists on getting strings + @classmethod + def quote_string(self, value): + return str(PostgreSQL.quote(value)) + + @classmethod def quote(self, value): """ Returns quoted version of the specified value. @@ -97,12 +103,11 @@ class PostgreSQL: # The pgdb._quote function is good enough for general SQL # quoting, except for array types. if isinstance(value, (list, tuple, set)): - return "ARRAY[%s]" % ", ".join(map, self.quote, value) + return "ARRAY[%s]" % ", ".join(map (PostgreSQL.quote_string, value)) else: return pgdb._quote(value) - quote = classmethod(quote) - + @classmethod def param(self, name, value): # None is converted to the unquoted string NULL if isinstance(value, NoneType): @@ -119,8 +124,6 @@ class PostgreSQL: return '%(' + name + ')' + conversion - param = classmethod(param) - def begin_work(self): # Implicit in pgdb.connect() pass