mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
fix: fix the conditional, apply to default too, early exit in column creation
This commit is contained in:
parent
9f3bd96053
commit
1390651803
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user