Merge branch 'anci-develop' into develop

This commit is contained in:
Itai Shirav 2017-10-30 15:07:58 +02:00
commit 33a8cf4be4

View File

@ -106,9 +106,13 @@ class Database(object):
if first_instance.readonly or first_instance.system: if first_instance.readonly or first_instance.system:
raise DatabaseException("You can't insert into read only and system tables") raise DatabaseException("You can't insert into read only and system tables")
fields_list = ','.join(
['`%s`' % name for name, _ in first_instance._writable_fields])
def gen(): def gen():
buf = BytesIO() buf = BytesIO()
buf.write(self._substitute('INSERT INTO $table FORMAT TabSeparated\n', model_class).encode('utf-8')) query = 'INSERT INTO $table (%s) FORMAT TabSeparated\n' % fields_list
buf.write(self._substitute(query, model_class).encode('utf-8'))
first_instance.set_database(self) first_instance.set_database(self)
buf.write(first_instance.to_tsv(include_readonly=False).encode('utf-8')) buf.write(first_instance.to_tsv(include_readonly=False).encode('utf-8'))
buf.write('\n'.encode('utf-8')) buf.write('\n'.encode('utf-8'))