fix: empty row on handler function
Closes https://github.com/PostgREST/postgrest/issues/3126
This commit is contained in:
committed by
Laurence Isla
parent
ec0f99c686
commit
cd62e39cd1
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- #3124, Fix table's media type handlers not working for all schemas - @steve-chavez
|
- #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
|
## [12.0.1] - 2023-12-12
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,8 @@ preparePlanRows countQuery =
|
|||||||
standardRow :: Bool -> HD.Row ResultSet
|
standardRow :: Bool -> HD.Row ResultSet
|
||||||
standardRow noLocation =
|
standardRow noLocation =
|
||||||
RSStandard <$> nullableColumn HD.int8 <*> column HD.int8
|
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.bytea
|
||||||
<*> nullableColumn HD.text
|
<*> nullableColumn HD.text
|
||||||
<*> nullableColumn HD.int8
|
<*> nullableColumn HD.int8
|
||||||
|
|||||||
@@ -119,6 +119,13 @@ spec = describe "custom media types" $ do
|
|||||||
, matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"]
|
, 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
|
context "Proc that returns scalar based on a table" $ do
|
||||||
it "can get an image with Accept: image/png" $ do
|
it "can get an image with Accept: image/png" $ do
|
||||||
r <- request methodGet "/rpc/ret_image" (acceptHdrs "image/png") ""
|
r <- request methodGet "/rpc/ret_image" (acceptHdrs "image/png") ""
|
||||||
|
|||||||
Vendored
+5
@@ -3517,6 +3517,11 @@ returns setof test.lines as $$
|
|||||||
select * from lines;
|
select * from lines;
|
||||||
$$ language sql;
|
$$ 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 ()
|
create or replace function test.get_shop_bles ()
|
||||||
returns setof test.shop_bles as $$
|
returns setof test.shop_bles as $$
|
||||||
select * from shop_bles;
|
select * from shop_bles;
|
||||||
|
|||||||
Reference in New Issue
Block a user