Skip to content

Unexpected behavior of queries that include OR #153

@Lezek123

Description

@Lezek123

To Reproduce
Steps to reproduce the behavior:

  1. Go to http://194.233.167.225:4350/graphql
  2. Paste the query:
{
  channels(where: {
    id_in: ["1", "2", "3"],
    OR: [
      { title_contains: "test" },
      { description_contains: "test"  }
    ]
  }) {
    id
  }
}
  1. Hit the "Execute" button
  2. Notice results including channels other than 1, 2 and 3

Expected behavior
The OR condition is joined with other conditions using the default operator (AND)

Expected difference in SQL:

SELECT "channel"."id" AS _c0 FROM "channel" AS "channel"
-  WHERE (("channel"."id" IN ($1, $2, $3)) OR (position($4 in "channel"."title") > 0) OR (position($5 in "channel"."description") > 0))
+  WHERE (("channel"."id" IN ($1, $2, $3)) AND ((position($4 in "channel"."title") > 0) OR (position($5 in "channel"."description") > 0)))

Environment (please complete the following information):

  • @subsquid/graphql-server: 3.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions