def _insert(self, table, fields): table_rname = table.sqlsafe if fields: keys = ','.join(f.sqlsafe_name for f, v in fields) values = ','.join(self.expand(v, f.type) for f, v in fields) if table._id and table._insert_with_returning: self._last_insert = (table._id, 1) return 'INSERT INTO %s(%s) VALUES (%s) RETURNING %s;' % ( table_rname, keys, values, table._id.name) else: self._last_insert = None return 'INSERT INTO %s(%s) VALUES (%s);' % (table_rname, keys, values) else: self._last_insert return self._insert_empty(table)
|