From 0b84911d38321595cd191fcadedc0d0d6113f0a7 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Wed, 15 May 2013 11:20:30 -0500 Subject: [PATCH] allow tables with no primary keys --- VERSION | 2 +- gluon/dal.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 7026e79c..ac9168b6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.6-stable+timestamp.2013.05.14.00.28.50 +Version 2.4.6-stable+timestamp.2013.05.15.11.18.49 diff --git a/gluon/dal.py b/gluon/dal.py index fa554dd6..6a088f68 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -928,7 +928,7 @@ class BaseAdapter(ConnectionPool): foreign_key = ', '.join(pkeys), on_delete_action = field.ondelete) - if hasattr(table,'_primarykey'): + if getattr(table,'_primarykey',None): query = "CREATE TABLE %s(\n %s,\n %s) %s" % \ (tablename, fields, self.PRIMARY_KEY(', '.join(table._primarykey)),other) @@ -1775,7 +1775,7 @@ class BaseAdapter(ConnectionPool): LOGGER.debug('SQL: %s' % command) self.db._lastsql = command t0 = time.time() - ret = self.cursor.execute(command,*a[1:], **b) + ret = self.cursor.execute(command, *a[1:], **b) self.db._timings.append((command,time.time()-t0)) del self.db._timings[:-TIMINGSSIZE] return ret @@ -1856,7 +1856,7 @@ class BaseAdapter(ConnectionPool): if have_serializers: obj = serializers.json(obj) elif simplejson: - obj = simplejson.dumps(obj) + obj = simplejson.dumps(items) else: raise RuntimeError("missing simplejson") if not isinstance(obj,bytes): @@ -3366,6 +3366,7 @@ class VerticaAdapter(MSSQLAdapter): 'big-reference': 'BIGINT REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s', } + def EXTRACT(self, first, what): return "DATE_PART('%s', TIMESTAMP %s)" % (what, self.expand(first))