From 46d3fd92c9cb4e9286e28534cb0fc500b071bfcf Mon Sep 17 00:00:00 2001 From: mdipierro Date: Fri, 15 Feb 2013 17:24:37 -0600 Subject: [PATCH] _insert_empty, thanks Alan --- VERSION | 2 +- gluon/dal.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index d27fe888..bcb18326 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2013.02.15.10.50.49 +Version 2.4.1-alpha.2+timestamp.2013.02.15.17.23.54 diff --git a/gluon/dal.py b/gluon/dal.py index 14f7c460..733be7a9 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -1182,9 +1182,15 @@ class BaseAdapter(ConnectionPool): logfile.write('success!\n') def _insert(self, table, fields): - keys = ','.join(f.name for f, v in fields) - values = ','.join(self.expand(v, f.type) for f, v in fields) - return 'INSERT INTO %s(%s) VALUES (%s);' % (table, keys, values) + if fields: + keys = ','.join(f.name for f, v in fields) + values = ','.join(self.expand(v, f.type) for f, v in fields) + return 'INSERT INTO %s(%s) VALUES (%s);' % (table, keys, values) + else: + return self._insert_empty(table) + + def _insert_empty(self, table): + return 'INSERT INTO %s DEFAULT VALUES;' % table def insert(self, table, fields): query = self._insert(table,fields)