这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions server/src-lib/Hasura/RQL/GBoolExp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ mkColCompExp
mkColCompExp qual lhsCol = \case
AEQ val -> equalsBoolExpBuilder lhs val
ANE val -> notEqualsBoolExpBuilder lhs val
AIN vals -> S.BEEqualsAny lhs vals
ANIN vals -> S.BENot $ S.BEEqualsAny lhs vals
AIN vals -> handleEmptyAny vals
ANIN vals -> S.BENot $ handleEmptyAny vals
AGT val -> S.BECompare S.SGT lhs val
ALT val -> S.BECompare S.SLT lhs val
AGTE val -> S.BECompare S.SGTE lhs val
Expand Down Expand Up @@ -299,6 +299,9 @@ mkColCompExp qual lhsCol = \case
toTextArray arr =
S.SETyAnn (S.SEArray $ map (txtEncoder . PGValText) arr) S.textArrType

handleEmptyAny [] = S.BELit False
handleEmptyAny vals = S.BEEqualsAny lhs vals

getColExpDeps :: QualifiedTable -> AnnBoolExpFld a -> [SchemaDependency]
getColExpDeps tn = \case
AVCol colInfo _ ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
description: Select author and their articles (in empty array)
url: /v1alpha1/graphql
status: 200
response:
data:
author: []
query:
query: |
query {
author (
where: {name: {_in: [] }}
) {
name
articles{
id
title
content
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
description: Select author and their articles (not in empty array)
url: /v1alpha1/graphql
status: 200
response:
data:
author:
- name: Author 1
articles:
- id: 1
title: Article 1
content: Sample article content 1
- id: 2
title: Article 2
content: Sample article content 2
- name: Author 2
articles:
- id: 3
title: Article 3
content: Sample article content 3
- name: Author 3
articles:
- id: 4
title: Article 4
content: Sample article content 4

query:
query: |
query {
author (
where: {name: {_nin: [] }}
) {
name
articles{
id
title
content
}
}
}
6 changes: 6 additions & 0 deletions server/tests-py/test_graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ def test_author_article_where_less_than_or_equal(self, hge_ctx):
def test_author_article_where_in(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_in.yaml')

def test_author_article_where_in_empty_array(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_in_empty_array.yaml')

def test_author_article_where_nin_empty_array(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_nin_empty_array.yaml')

def test_author_article_where_nin(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_nin.yaml')

Expand Down