Skip to content

[BUG] Boolean fields aren't applied as filters in WHERE clauses #3317

@Swiddis

Description

@Swiddis

What is the bug?
Building on #3266, it turns out that variables as boolean clauses aren't applied correctly at all.

How can one reproduce the bug?

PUT test_index

POST _bulk
{ "create": { "_index": "test_index" } }
{ "x": 0, "y": false }
{ "create": { "_index": "test_index" } }
{ "x": 1, "y": true }
{ "create": { "_index": "test_index" } }
{ "x": 2, "y": null }

POST _plugins/_sql
{
  "query": "SELECT x FROM test_index WHERE y"
}
{
  "schema": [
    {
      "name": "x",
      "type": "long"
    }
  ],
  "datarows": [
    [0], [1], [2]
  ],
  "total": 3,
  "size": 3,
  "status": 200
}

What is the expected behavior?

{
  "schema": [
    {
      "name": "x",
      "type": "long"
    }
  ],
  "datarows": [
    [1]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}

What is your host/environment?

Do you have any screenshots?
N/A

Do you have any additional context?
Found by dynamic-testing via NoREC. Original failure:

Falsified after 0 passed tests.
> Labels of failing property: 
39 != 15
Optimizing:     SELECT j FROM test_34761613 WHERE z
Non-Optimizing: SELECT z FROM test_34761613 
> ARG_0: SELECT j, k FROM test_34761613 WHERE z

Metadata

Metadata

Assignees

Labels

SQLbugSomething isn't workingdynamic-testIssues found by or related to Dynamic Testingengine v2Issues related to v2 query engine only.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions