Skip to content

Commit

Permalink
Change error message for comp against fields (#57126)
Browse files Browse the repository at this point in the history
Change the error message wording for comparisons against fields in
filtering (s/variables/fields).

(cherry picked from commit d9a1cb5)
  • Loading branch information
bpintea committed May 26, 2020
1 parent 4f9f3e3 commit d16cd68
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ expected_event_ids = [82]
query = "file where serial_event_id / 2 == 41"

[[queries]]
# Error: Line 1:42: Comparisons against variables are not (currently) supported; offender [serial_event_id] in [==]
# Error: Line 1:42: Comparisons against fields are not (currently) supported; offender [serial_event_id] in [==]
query = '''
process where modulo(11, add(serial_event_id, 1)) == serial_event_id'''
expected_event_ids = [1, 2, 3, 5, 11]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ public void testPropertyEquationFilterUnsupported() {
QlIllegalArgumentException e = expectThrows(QlIllegalArgumentException.class,
() -> plan("process where (serial_event_id<9 and serial_event_id >= 7) or (opcode == pid)"));
String msg = e.getMessage();
assertEquals("Line 1:74: Comparisons against variables are not (currently) supported; offender [pid] in [==]", msg);
assertEquals("Line 1:74: Comparisons against fields are not (currently) supported; offender [pid] in [==]", msg);
}

public void testPropertyEquationInClauseFilterUnsupported() {
VerificationException e = expectThrows(VerificationException.class,
() -> plan("process where opcode in (1,3) and process_name in (parent_process_name, \"SYSTEM\")"));
String msg = e.getMessage();
assertEquals("Found 1 problem\nline 1:35: Comparisons against variables are not (currently) supported; " +
assertEquals("Found 1 problem\nline 1:35: Comparisons against fields are not (currently) supported; " +
"offender [parent_process_name] in [process_name in (parent_process_name, \"SYSTEM\")]", msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected TypeResolution resolveType() {

for (Expression ex : list) {
if (ex.foldable() == false) {
return new TypeResolution(format(null, "Comparisons against variables are not (currently) supported; offender [{}] in [{}]",
return new TypeResolution(format(null, "Comparisons against fields are not (currently) supported; offender [{}] in [{}]",
Expressions.name(ex),
sourceText()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ protected Query asQuery(BinaryComparison bc, TranslatorHandler handler) {

public static void checkBinaryComparison(BinaryComparison bc) {
Check.isTrue(bc.right().foldable(),
"Line {}:{}: Comparisons against variables are not (currently) supported; offender [{}] in [{}]",
"Line {}:{}: Comparisons against fields are not (currently) supported; offender [{}] in [{}]",
bc.right().sourceLocation().getLineNumber(), bc.right().sourceLocation().getColumnNumber(),
Expressions.name(bc.right()), bc.symbol());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public void testInWithDifferentDataTypesFromLeftValue() {
}

public void testInWithFieldInListOfValues() {
assertEquals("1:26: Comparisons against variables are not (currently) supported; offender [int] in [int IN (1, int)]",
assertEquals("1:26: Comparisons against fields are not (currently) supported; offender [int] in [int IN (1, int)]",
error("SELECT * FROM test WHERE int IN (1, int)"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public void testComparisonAgainstColumns() {
assertTrue(p instanceof Filter);
Expression condition = ((Filter) p).condition();
QlIllegalArgumentException ex = expectThrows(QlIllegalArgumentException.class, () -> translate(condition));
assertEquals("Line 1:43: Comparisons against variables are not (currently) supported; offender [int] in [>]", ex.getMessage());
assertEquals("Line 1:43: Comparisons against fields are not (currently) supported; offender [int] in [>]", ex.getMessage());
}

public void testDateRange() {
Expand Down

0 comments on commit d16cd68

Please sign in to comment.