wpt.fyi icon indicating copy to clipboard operation
wpt.fyi copied to clipboard

Search query: `and` behaves unexpectedly within a root query

Open Hexcles opened this issue 5 years ago • 1 comments

With the introduction of root queries (exists, count, none, all, etc.), and now behaves somewhat unexpectedly and our doc is inconsistent/inaccurate on this regard.

For example, chrome:pass firefox:fail works as expected whereas chrome:pass and firefox:fail will never match anything.

Under the hood, this is because exists is added implicitly as the root (top-level) query, i.e. exists(chrome:pass firefox:fail) and exists(chrome:pass and firefox:fail). The former in fact has two queries within exist, while the latter has only one:

exists
* chrome:pass
* firefox:fail

vs

exists
* and
  * chrome:pass
  * firefox:fail

The semantic of exists is that each queries must match some result in a row for the row to be selected, so the first one works while the latter one doesn't (a result is either from Chrome or Firefox, so it can never match the and query).

We should at least fix the doc to clarify that and only applies implicitly to root level queries (e.g. exists(query1) and none(query2)), remove bad examples and add some reminders.

Besides, we might want to document or tweak the grammar in a more logical, consistent structure.

Hexcles avatar Oct 13 '20 15:10 Hexcles

I have a feeling that exists is the root cause of confusion here.

Another example: chrome:fail or (chrome:pass and firefox:fail) doesn't really work, as it (counter-intuitively) becomes exists(chrome:fail or (chrome:pass and firefox:fail)). The right query is exists(chrome:fail) or exists(chrome:pass firefox:fail) (also note the absence of and here, due to reasons above) which is quite cumbersome.

Hexcles avatar Oct 13 '20 18:10 Hexcles

Fixed in prod. Future improvement in https://github.com/web-platform-tests/wpt.fyi/issues/3323

KyleJu avatar May 23 '23 17:05 KyleJu