Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow filtering on null #82

Merged
merged 1 commit into from
Feb 13, 2016
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
4 changes: 4 additions & 0 deletions lib/ast/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Linter extends ASTVisitor {
this[`visit${node.type}`].apply(this, arguments);
}

visitNullLiteral(node, options) {
throw new Error('Filtering null values is not supported');
}

visitSimpleFilterTerm(node, options) {
if (node.expression.type === 'StringLiteral') {
throw new Error('Full text search is not supported');
Expand Down
13 changes: 13 additions & 0 deletions test/ast/lint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ describe('query linting', () => {
});
});

it('doesnt allow null filters', () => {
var tests = [
'field != null',
'field = null',
'field1 = null or field2 = "1"',
];

_.each(tests, (test) => {
var ast = utils.parseFilter(test);
expect(linter.lint.bind(linter, ast, { nameField: 'name' })).to.throw(/Filtering null values is not supported/);
});
});

it('doesnt allow FTS filters', () => {
var tests = [
'"some string"',
Expand Down
5 changes: 0 additions & 5 deletions test/query/query.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ describe('influxql query building', () => {
expect(builder.build({ nameField: 'name' }, { filter_ast })).to.equal('SELECT * FROM /.*/ WHERE "key" = 1');
});

it('simple filter null', () => {
var filter_ast = utils.parseFilter('key = null');
expect(builder.build({ nameField: 'name' }, { filter_ast })).to.equal('SELECT * FROM /.*/ WHERE "key" = null');
});

it('implicit and', () => {
var filter_ast = utils.parseFilter('key1 = "val1" key2 = "val2"');
expect(builder.build({ nameField: 'name' }, { filter_ast })).to.equal('SELECT * FROM /.*/ WHERE "key1" = \'val1\' AND "key2" = \'val2\'');
Expand Down