diff options
author | Marko Kreen | 2011-12-29 09:59:44 +0000 |
---|---|---|
committer | Marko Kreen | 2011-12-29 09:59:44 +0000 |
commit | 493709b3d97d406fcfaefb59469538780c874c4c (patch) | |
tree | 6514efe7588a19683f68d45cae11c9f4fd8ae1ec | |
parent | 5883fa0d25f74d4cf06f0a8354dd95fe51d2a760 (diff) |
dbservice.TableAPI: cast id to int8
This makes possible to use prepared plans with tapi.
-rwxr-xr-x | python/skytools/dbservice.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/python/skytools/dbservice.py b/python/skytools/dbservice.py index ee06a872..4a64555f 100755 --- a/python/skytools/dbservice.py +++ b/python/skytools/dbservice.py @@ -340,12 +340,13 @@ class TableAPI: _table = None # schema name and table name _where = None # where condition used for update and delete _id = None # name of the primary key filed + _id_type = None # column type of primary key _op = None # operation currently carried out _ctx = None # context object for username and version _logging = True # should tapi log data changed _row = None # row identifer from calling program - def __init__(self, ctx, table, create_log = True ): + def __init__(self, ctx, table, create_log = True, id_type='int8' ): """ Table name is used to construct insert update and delete statements Table must have primary key field whose name is in format id_<table> Tablename should be in format schema.tablename @@ -353,7 +354,8 @@ class TableAPI: self._ctx = ctx self._table = skytools.quote_fqident(table) self._id = "id_" + skytools.fq_name_parts(table)[1] - self._where = skytools.quote_ident(self._id) + " = {" + self._id + "}" + self._id_type = id_type + self._where = '%s = {%s:%s}' % (skytools.quote_ident(self._id), self._id, self._id_type) self._logging = create_log def _log(self, result, original = None): |