2
0
mirror of https://github.com/frappe/books.git synced 2025-01-08 17:24:05 +00:00

query builder: imperative to declarative 😠

This commit is contained in:
Prateeksha Singh 2018-03-29 19:58:31 +05:30
parent beffd73259
commit 01a7a31a0d

View File

@ -74,16 +74,14 @@ module.exports = class sqliteDatabase extends Database {
}
getColumnDefinition(field) {
let def = `${field.fieldname} ${this.typeMap[field.fieldtype]}`;
if (field.fieldname==='name') {
def += ' PRIMARY KEY NOT NULL';
}
else if (field.required) {
def += ' NOT NULL';
}
if (field.default) {
def += `DEFAULT ${field.default}`;
}
let def = [
field.fieldname,
this.typeMap[field.fieldtype],
field.fieldname === 'name' ? 'PRIMARY KEY NOT NULL' : '',
field.required ? 'NOT NULL' : '',
field.default ? `DEFAULT ${field.default}` : ''
].join(' ');
return def;
}