subsquid / squid-sdk

The main repo of the squid SDK
Apache License 2.0
1.23k stars 151 forks source link

Unexpected behavior of queries that include `OR` #153

Closed Lezek123 closed 1 year ago

Lezek123 commented 1 year ago

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
    }
    }
  3. Hit the "Execute" button
  4. 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):

eldargab commented 1 year ago

Interesting, that both Hasura and Warthog behave the way you suggest, but I'm afraid it is too late to make breaking changes like this one...

dzhelezov commented 1 year ago

Closing as "Won't fix"