fix: empty row on handler function

Closes https://github.com/PostgREST/postgrest/issues/3126
This commit is contained in:
steve-chavez
2023-12-20 16:18:09 -05:00
committed by Steve Chavez
parent 1680a6eed3
commit 3af63cb94c
4 changed files with 15 additions and 1 deletions
+1
View File
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- #3124, Fix table's media type handlers not working for all schemas - @steve-chavez
- #3126, Fix empty row on media type handler function - @steve-chavez
## [12.0.1] - 2023-12-12
+2 -1
View File
@@ -157,7 +157,8 @@ preparePlanRows countQuery =
standardRow :: Bool -> HD.Row ResultSet
standardRow noLocation =
RSStandard <$> nullableColumn HD.int8 <*> column HD.int8
<*> (if noLocation then pure mempty else fmap splitKeyValue <$> arrayColumn HD.bytea) <*> column HD.bytea
<*> (if noLocation then pure mempty else fmap splitKeyValue <$> arrayColumn HD.bytea)
<*> (fromMaybe mempty <$> nullableColumn HD.bytea)
<*> nullableColumn HD.bytea
<*> nullableColumn HD.text
<*> nullableColumn HD.int8
@@ -119,6 +119,13 @@ spec = describe "custom media types" $ do
, matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"]
}
it "should not fail when the function doesn't return a row" $ do
request methodGet "/rpc/get_line?id=777" (acceptHdrs "application/vnd.twkb") ""
`shouldRespondWith` ""
{ matchStatus = 200
, matchHeaders = ["Content-Type" <:> "application/vnd.twkb"]
}
context "Proc that returns scalar based on a table" $ do
it "can get an image with Accept: image/png" $ do
r <- request methodGet "/rpc/ret_image" (acceptHdrs "image/png") ""
+5
View File
@@ -3517,6 +3517,11 @@ returns setof test.lines as $$
select * from lines;
$$ language sql;
create or replace function test.get_line (id int)
returns "application/vnd.twkb" as $$
select extensions.st_astwkb(geom)::"application/vnd.twkb" from lines where id = get_line.id;
$$ language sql;
create or replace function test.get_shop_bles ()
returns setof test.shop_bles as $$
select * from shop_bles;