From 4ffb29c5fdf237ca22d02a76258845d17728abf9 Mon Sep 17 00:00:00 2001 From: Laurence Isla Date: Thu, 14 Sep 2023 20:21:38 -0500 Subject: [PATCH] Add is.null test --- test/spec/Feature/Query/RelatedQueriesSpec.hs | 15 +++++++++++---- test/spec/fixtures/data.sql | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/spec/Feature/Query/RelatedQueriesSpec.hs b/test/spec/Feature/Query/RelatedQueriesSpec.hs index bd25a91577..0b83cbb680 100644 --- a/test/spec/Feature/Query/RelatedQueriesSpec.hs +++ b/test/spec/Feature/Query/RelatedQueriesSpec.hs @@ -257,14 +257,21 @@ spec = describe "related queries" $ do , matchHeaders = [matchContentTypeJson] } - -- "?table=not.is.null" does a "NOT table IS NULL" instead of a "table IS NOT NULL" - -- https://github.com/PostgREST/postgrest/issues/2800#issuecomment-1562620508 - it "embeds even if the target relationship has a row with a NULL value in any of its columns" $ + -- "?table=not.is.null" does a "table IS DISTINCT FROM NULL" instead of a "table IS NOT NULL" + -- https://github.com/PostgREST/postgrest/issues/2800#issuecomment-1720315818 + it "embeds verifying that the entire target table row is not null" $ do get "/table_b?select=name,table_a(name)&table_a=not.is.null" `shouldRespondWith` [json|[ - {"name":"Test 1","table_a":{"name":"Not null"}}, + {"name":"Test 1","table_a":{"name":"Not null 1"}}, {"name":"Test 2","table_a":{"name":null}} ]|] { matchStatus = 200 , matchHeaders = [matchContentTypeJson] } + get "/table_b?select=name,table_a()&table_a=is.null" `shouldRespondWith` + [json|[ + {"name":"Test 3"} + ]|] + { matchStatus = 200 + , matchHeaders = [matchContentTypeJson] + } diff --git a/test/spec/fixtures/data.sql b/test/spec/fixtures/data.sql index 1d54d14bcb..b3f478fc7f 100644 --- a/test/spec/fixtures/data.sql +++ b/test/spec/fixtures/data.sql @@ -855,6 +855,6 @@ INSERT INTO bitchar_with_length(bit, char) VALUES ('00000', 'aaaaa'); INSERT INTO bitchar_with_length(bit, char) VALUES ('11111', 'bbbbb'); TRUNCATE TABLE table_a CASCADE; -INSERT INTO table_a(id, name) VALUES (1, 'Not null'), (2, null); +INSERT INTO table_a(id, name) VALUES (1, 'Not null 1'), (2, null), (3, 'Not null 2'); TRUNCATE TABLE table_b CASCADE; -INSERT INTO table_b(table_a_id, name) VALUES (1, 'Test 1'), (2, 'Test 2'); +INSERT INTO table_b(table_a_id, name) VALUES (1, 'Test 1'), (2, 'Test 2'), (null, 'Test 3');