Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Issue 569 - Support empty strings in filter query #570

Merged
merged 2 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Fixed
[#569](https://github.com/plotly/dash-table/issues/569), [#544](https://github.com/plotly/dash-table/issues/544)
- Allow empty strings in all `filter_query` (e.g filter_query: '{colA} eq ""')

[#567](https://github.com/plotly/dash-table/issues/567)
- Add support for missing `border-radius` in style_** props
- Fix table's inner vs. outer container styling
Expand Down
2 changes: 1 addition & 1 deletion src/dash-table/syntax-tree/lexeme/expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { LexemeType, IUnboundedLexeme } from 'core/syntax-tree/lexicon';
import { ISyntaxTree } from 'core/syntax-tree/syntaxer';

const FIELD_REGEX = /^{(([^{}\\]|\\.)+)}/;
const STRING_REGEX = /^(('([^'\\]|\\.)+')|("([^"\\]|\\.)+")|(`([^`\\]|\\.)+`))/;
const STRING_REGEX = /^(('([^'\\]|\\.)*')|("([^"\\]|\\.)*")|(`([^`\\]|\\.)*`))/;
const VALUE_REGEX = /^(([^\s'"`{}()\\]|\\.)+)(?:[\s)]|$)/;

const getField = (
Expand Down
1 change: 1 addition & 0 deletions tests/cypress/tests/unit/lexeme_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('expression', () => {
expect(typeof stringExpression.resolve).to.equal('function');

if (stringExpression.resolve) {
expect(stringExpression.resolve(undefined, { value: '\'\'' } as ISyntaxTree)).to.equal('');
expect(stringExpression.resolve(undefined, { value: '\'abc\'' } as ISyntaxTree)).to.equal('abc');
expect(stringExpression.resolve(undefined, { value: '"abc"' } as ISyntaxTree)).to.equal('abc');
expect(stringExpression.resolve(undefined, { value: '`abc`' } as ISyntaxTree)).to.equal('abc');
Expand Down
9 changes: 9 additions & 0 deletions tests/cypress/tests/unit/query_syntactic_tree_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ describe('Query Syntax Tree', () => {
expect(tree.evaluate(data2)).to.equal(false);
expect(tree.evaluate(data3)).to.equal(false);
});

it('can compare to empty string', () => {
const tree = new QuerySyntaxTree('{c} eq ""');

expect(tree.isValid).to.equal(true);
expect(tree.evaluate({ c: 'a' })).to.equal(false);
expect(tree.evaluate({ c: ' ' })).to.equal(false);
expect(tree.evaluate({ c: '' })).to.equal(true);
});
});

describe('block', () => {
Expand Down