fix: database test cases and table options (#28)

This commit is contained in:
Junyi 2020-12-02 15:54:19 +08:00 committed by GitHub
parent 868dd1aaaa
commit dd1d4fc7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View File

@ -90,6 +90,7 @@ describe('toInclude', () => {
association: 'bars', association: 'bars',
} }
], ],
distinct: true,
}); });
}); });
@ -104,6 +105,7 @@ describe('toInclude', () => {
attributes: [ 'col1', 'col2' ], attributes: [ 'col1', 'col2' ],
} }
], ],
distinct: true,
}); });
}); });
@ -118,6 +120,7 @@ describe('toInclude', () => {
attributes: [ 'col1', 'col2' ], attributes: [ 'col1', 'col2' ],
} }
], ],
distinct: true,
}); });
}); });
@ -137,6 +140,7 @@ describe('toInclude', () => {
] ]
} }
], ],
distinct: true,
}); });
}); });
@ -156,6 +160,7 @@ describe('toInclude', () => {
] ]
} }
], ],
distinct: true,
}); });
}); });
@ -175,6 +180,7 @@ describe('toInclude', () => {
] ]
} }
], ],
distinct: true,
}); });
}); });
@ -196,6 +202,7 @@ describe('toInclude', () => {
] ]
} }
], ],
distinct: true,
}); });
}); });
@ -227,7 +234,8 @@ describe('toInclude', () => {
include: ['col1'], include: ['col1'],
}, },
} }
] ],
distinct: true,
}); });
}); });
@ -256,6 +264,7 @@ describe('toInclude', () => {
attributes: ['col1'], attributes: ['col1'],
} }
], ],
distinct: true,
}); });
}); });
@ -266,7 +275,6 @@ describe('toInclude', () => {
}, },
}).toEqual({ }).toEqual({
attributes: { attributes: {
include: [],
exclude: ['col1'], exclude: ['col1'],
}, },
}); });
@ -279,18 +287,17 @@ describe('toInclude', () => {
}, },
}).toEqual({ }).toEqual({
attributes: { attributes: {
include: [],
exclude: ['col1'], exclude: ['col1'],
}, },
include: [ include: [
{ {
association: 'bars', association: 'bars',
attributes: { attributes: {
include: [],
exclude: ['col1'], exclude: ['col1'],
} }
} }
] ],
distinct: true,
}); });
}); });
@ -356,7 +363,8 @@ describe('toInclude', () => {
col1: 'val1', col1: 'val1',
} }
} }
] ],
distinct: true,
}); });
}); });
@ -387,7 +395,8 @@ describe('toInclude', () => {
col1: 'val1', col1: 'val1',
} }
} }
] ],
distinct: true,
}); });
}); });

View File

@ -279,6 +279,9 @@ export class Table {
}); });
// 添加字段后 table.options 中的 fields 并不会更新,这导致 table.getOptions() 拿不到最新的字段配置 // 添加字段后 table.options 中的 fields 并不会更新,这导致 table.getOptions() 拿不到最新的字段配置
// 所以在同时更新 table.options.fields 数组 // 所以在同时更新 table.options.fields 数组
if (!this.options.fields) {
this.options.fields = [];
}
const existIndex = this.options.fields.findIndex(field => field.name === name); const existIndex = this.options.fields.findIndex(field => field.name === name);
if (existIndex !== -1) { if (existIndex !== -1) {
this.options.fields.splice(existIndex, 1, options); this.options.fields.splice(existIndex, 1, options);