2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 20:00:29 +00:00

fix: fix the conditional, apply to default too, early exit in column creation

This commit is contained in:
18alantom 2021-11-08 15:14:02 +05:30
parent 9f3bd96053
commit 1390651803

View File

@ -113,6 +113,12 @@ module.exports = class Database extends Observable {
buildColumnForTable(table, field) {
let columnType = this.getColumnType(field);
if (!columnType) {
// In case columnType is "Table"
// childTable links are handled using the childTable's "parent" field
return;
}
let column = table[columnType](field.fieldname);
// primary key
@ -121,12 +127,12 @@ module.exports = class Database extends Observable {
}
// default value
if (field.default) {
if (!!field.default && !(field.default instanceof Function)) {
column.defaultTo(field.default);
}
// required
if (field.required && !field.required instanceof Function) {
if (!!field.required && !(field.required instanceof Function)) {
column.notNullable();
}