(objValue, srcValue, key)
| 821 | } |
| 822 | |
| 823 | static _mergeFunction(objValue, srcValue, key) { |
| 824 | if (Array.isArray(objValue) && Array.isArray(srcValue)) { |
| 825 | return _.union(objValue, srcValue); |
| 826 | } |
| 827 | |
| 828 | if (['where', 'having'].includes(key)) { |
| 829 | if (this.options && this.options.whereMergeStrategy === 'and') { |
| 830 | return combineWheresWithAnd(objValue, srcValue); |
| 831 | } |
| 832 | |
| 833 | if (srcValue instanceof Utils.SequelizeMethod) { |
| 834 | srcValue = { [Op.and]: srcValue }; |
| 835 | } |
| 836 | |
| 837 | if (_.isPlainObject(objValue) && _.isPlainObject(srcValue)) { |
| 838 | return Object.assign(objValue, srcValue); |
| 839 | } |
| 840 | } else if (key === 'attributes' && _.isPlainObject(objValue) && _.isPlainObject(srcValue)) { |
| 841 | return _.assignWith(objValue, srcValue, (objValue, srcValue) => { |
| 842 | if (Array.isArray(objValue) && Array.isArray(srcValue)) { |
| 843 | return _.union(objValue, srcValue); |
| 844 | } |
| 845 | }); |
| 846 | } |
| 847 | // If we have a possible object/array to clone, we try it. |
| 848 | // Otherwise, we return the original value when it's not undefined, |
| 849 | // or the resulting object in that case. |
| 850 | if (srcValue) { |
| 851 | return Utils.cloneDeep(srcValue, true); |
| 852 | } |
| 853 | return srcValue === undefined ? objValue : srcValue; |
| 854 | } |
| 855 | |
| 856 | static _assignOptions(...args) { |
| 857 | return this._baseMerge(...args, this._mergeFunction.bind(this)); |
no test coverage detected