forest-express-sequelize 8.4.4 → 8.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [8.4.5](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.4...v8.4.5) (2021-10-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* nested include duplication in smart field search ([#863](https://github.com/ForestAdmin/forest-express-sequelize/issues/863)) ([d61da0c](https://github.com/ForestAdmin/forest-express-sequelize/commit/d61da0c2b9dbf337e26ac1f2d816855787023afe))
|
|
7
|
+
|
|
1
8
|
## [8.4.4](https://github.com/ForestAdmin/forest-express-sequelize/compare/v8.4.3...v8.4.4) (2021-10-20)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -119,7 +119,7 @@ function SearchBuilder(model, opts, params, fieldNamesRequested) {
|
|
|
119
119
|
try {
|
|
120
120
|
await field.search(query, params.search);
|
|
121
121
|
} catch (error) {
|
|
122
|
-
const errorMessage = `Cannot search properly on Smart Field ${field.field}`;
|
|
122
|
+
const errorMessage = `Cannot search properly on Smart Field ${field.field}: `;
|
|
123
123
|
Interface.logger.error(errorMessage, error);
|
|
124
124
|
}
|
|
125
125
|
|
|
@@ -156,8 +156,9 @@ function removeDuplicateAssociations(model, includeList) {
|
|
|
156
156
|
|
|
157
157
|
|
|
158
158
|
includeList.forEach(function (include) {
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
const association = model.associations[include.as];
|
|
160
|
+
|
|
161
|
+
if (include.include && association) {
|
|
161
162
|
removeDuplicateAssociations(association.target, include.include);
|
|
162
163
|
}
|
|
163
164
|
});
|
package/package.json
CHANGED
|
@@ -84,7 +84,7 @@ describe('services > query-options', () => {
|
|
|
84
84
|
|
|
85
85
|
const options = new QueryOptions(model);
|
|
86
86
|
await options.search('search string', null);
|
|
87
|
-
expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField', errorThrown);
|
|
87
|
+
expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField: ', errorThrown);
|
|
88
88
|
|
|
89
89
|
loggerErrorSpy.mockClear();
|
|
90
90
|
resetSchema();
|
|
@@ -122,7 +122,7 @@ describe('services > query-options', () => {
|
|
|
122
122
|
|
|
123
123
|
const options = new QueryOptions(model);
|
|
124
124
|
await options.search('search string', null);
|
|
125
|
-
expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField', errorThrown);
|
|
125
|
+
expect(loggerErrorSpy).toHaveBeenCalledWith('Cannot search properly on Smart Field smartField: ', errorThrown);
|
|
126
126
|
|
|
127
127
|
loggerErrorSpy.mockClear();
|
|
128
128
|
resetSchema();
|
|
@@ -252,4 +252,26 @@ describe('utils > sequelize-compatibility', () => {
|
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
});
|
|
255
|
+
|
|
256
|
+
describe('postProcess -> removeDuplicateAssociations', () => {
|
|
257
|
+
describe('when include alias is not valid', () => {
|
|
258
|
+
it('should not throw an error', () => {
|
|
259
|
+
expect.assertions(1);
|
|
260
|
+
|
|
261
|
+
const include = [{ model: SubModel, as: 'notAValidAlias', include: SubModel }];
|
|
262
|
+
|
|
263
|
+
expect(() => postProcess(Model, { include })).not.toThrow();
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe('when the main model is reincluded', () => {
|
|
268
|
+
it('should not throw an error', () => {
|
|
269
|
+
expect.assertions(1);
|
|
270
|
+
|
|
271
|
+
const include = [{ model: Model, include: SubSubModel1 }];
|
|
272
|
+
|
|
273
|
+
expect(() => postProcess(Model, { include })).not.toThrow();
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
});
|
|
255
277
|
});
|