2
0
mirror of https://github.com/frappe/books.git synced 2025-01-24 15:48:25 +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) { getColumnDefinition(field) {
let def = `${field.fieldname} ${this.typeMap[field.fieldtype]}`; let def = [
if (field.fieldname==='name') { field.fieldname,
def += ' PRIMARY KEY NOT NULL'; this.typeMap[field.fieldtype],
} field.fieldname === 'name' ? 'PRIMARY KEY NOT NULL' : '',
else if (field.required) { field.required ? 'NOT NULL' : '',
def += ' NOT NULL'; field.default ? `DEFAULT ${field.default}` : ''
} ].join(' ');
if (field.default) {
def += `DEFAULT ${field.default}`;
}
return def; return def;
} }