This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Support relations #1
Labels
Comments
This was referenced Oct 7, 2018
18 tasks
This was referenced Nov 7, 2018
naz
added a commit
to naz/NQL-legacy
that referenced
this issue
Nov 16, 2018
refs TryGhost#1 - this version includes more filtering options by relations (like $or and $and conjunctions)
This is done. The feature was added in mongo-knex. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Description
NQL currently does not support relations filtering. It generates the wrong SQL query e.g. if you pass
filter=tags:[video]
.Problems to be mitigated when substituting GQL
GQL supports relations, but they are broken:
General bug categories:
tag:-en
)tag:-en
, the returned filter didn't include entities which hadtag = null
tag:-en
and the entity had other tags e.g.:es, en
it still returned this entity (didn't work as they were being achieved throughhaving count()
on individual tags)tag:en, es
)or
conjunction. the query that is being build usesin (...)
which only accounts foror
schenarios (it is missing having count to support and)count.posts:>0
)Why was GQL broken?
GQL used the following strategy:
IN
operator to compare the input valuesgroup by
to return distinct resultsExample GQL query:
The query works for some cases, but not for all cases.
IN
operator is an instrument to satisfy OR conjunctionstag:-en
, would not return results which have no relation attached, becausetags.slug
is null (!)How relational filtering could be achieved
Based on our research the most viable solution would be generating sub-queries. Example raw generated query for
posts
withtag:en
filter would be:this could be generated with followign equivalent in knex:
alternatively for performance reasons query could be also built with following structure to avoid performance degradation:
List of queries that prove all of the relational filtering types can be achieved with subqueries - https://gist.github.com/gargol/05aea3902981516c5ed6074b5664197f
Post implementation cleanup notes
These test cases will have to be adjusted/expanded upon when working on this issue:
The text was updated successfully, but these errors were encountered: