fix: null value and empty string in filter (#18171)

This commit is contained in:
Yongjie Zhao
2022-01-27 22:58:06 +08:00
committed by GitHub
parent dbe0a8b519
commit 20b4ae1ef9
10 changed files with 102 additions and 41 deletions

View File

@@ -16,7 +16,9 @@
* specific language governing permissions and limitations
* under the License.
*/
import { EMPTY_STRING, NULL_STRING } from 'src/utils/common';
import { getSimpleSQLExpression } from '.';
import { Operators } from '../constants';
const params = {
subject: 'subject',
@@ -36,6 +38,12 @@ test('Should return "" if subject is falsy', () => {
).toBe('');
});
test('Should return null string and empty string', () => {
expect(getSimpleSQLExpression(params.subject, Operators.IN, [null, ''])).toBe(
`subject ${Operators.IN} (${NULL_STRING}, ${EMPTY_STRING})`,
);
});
test('Should return subject if operator is falsy', () => {
expect(getSimpleSQLExpression(params.subject, '', params.comparator)).toBe(
params.subject,