diff --git a/CHANGELOG.md b/CHANGELOG.md index b3009d41d..457becbaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - #3205, Fix wrong subquery error returning a status of 400 Bad Request - @steve-chavez - #3224, Return status code 406 for non-accepted media type instead of code 415 - @wolfgangwalther - #3160, Fix using select= query parameter for custom media type handlers - @wolfgangwalther + - #3361, Clarify PGRST204(column not found) error message - @steve-chavez ## [12.0.2] - 2023-12-20 diff --git a/src/PostgREST/Error.hs b/src/PostgREST/Error.hs index 2881e0953..176e7282b 100644 --- a/src/PostgREST/Error.hs +++ b/src/PostgREST/Error.hs @@ -242,7 +242,7 @@ instance JSON.ToJSON ApiRequestError where (Just "Try renaming the parameters or the function itself in the database so function overloading can be resolved") toJSON (ColumnNotFound relName colName) = toJsonPgrstError - SchemaCacheErrorCode04 ("Column '" <> colName <> "' of relation '" <> relName <> "' does not exist") Nothing Nothing + SchemaCacheErrorCode04 ("Could not find the '" <> colName <> "' column of '" <> relName <> "' in the schema cache") Nothing Nothing -- | -- If no relationship is found then: diff --git a/test/spec/Feature/Query/InsertSpec.hs b/test/spec/Feature/Query/InsertSpec.hs index 817319912..934c65b0f 100644 --- a/test/spec/Feature/Query/InsertSpec.hs +++ b/test/spec/Feature/Query/InsertSpec.hs @@ -453,7 +453,7 @@ spec actualPgVersion = do {"id": 204, "body": "yyy"}, {"id": 205, "body": "zzz"}]|] `shouldRespondWith` - [json|{"code":"PGRST204","details":null,"hint":null,"message":"Column 'helicopter' of relation 'articles' does not exist"} |] + [json|{"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'helicopter' column of 'articles' in the schema cache"} |] { matchStatus = 400 , matchHeaders = [] } @@ -835,7 +835,7 @@ spec actualPgVersion = do request methodPost "/datarep_todos?columns=id,label_color,helicopters&select=id,name,label_color,due_at" [("Prefer", "return=representation")] [json| {"due_at": "2019-01-03T11:00:00+00", "smth": "here", "label_color": "invalid", "fake_id": 13} |] `shouldRespondWith` - [json| {"code":"PGRST204","message":"Column 'helicopters' of relation 'datarep_todos' does not exist","details":null,"hint":null} |] + [json| {"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'helicopters' column of 'datarep_todos' in the schema cache"} |] { matchStatus = 400 , matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"] } @@ -890,7 +890,7 @@ spec actualPgVersion = do request methodPost "/datarep_todos_computed?columns=id,label_color,helicopters&select=id,name,label_color,due_at" [("Prefer", "return=representation")] [json| {"due_at": "2019-01-03T11:00:00+00", "smth": "here", "label_color": "invalid", "fake_id": 13} |] `shouldRespondWith` - [json| {"code":"PGRST204","message":"Column 'helicopters' of relation 'datarep_todos_computed' does not exist","details":null,"hint":null} |] + [json| {"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'helicopters' column of 'datarep_todos_computed' in the schema cache"} |] { matchStatus = 400 , matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"] } diff --git a/test/spec/Feature/Query/UpdateSpec.hs b/test/spec/Feature/Query/UpdateSpec.hs index 7cf701304..dd2504d24 100644 --- a/test/spec/Feature/Query/UpdateSpec.hs +++ b/test/spec/Feature/Query/UpdateSpec.hs @@ -333,7 +333,7 @@ spec actualPgVersion = do [("Prefer", "return=representation")] [json|{"body": "yyy"}|] `shouldRespondWith` - [json|{"code":"PGRST204","details":null,"hint":null,"message":"Column 'helicopter' of relation 'articles' does not exist"} |] + [json|{"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'helicopter' column of 'articles' in the schema cache"}|] { matchStatus = 400 , matchHeaders = [] } @@ -879,7 +879,7 @@ spec actualPgVersion = do request methodPatch "/datarep_todos?id=eq.2&columns=label_color,helicopters" [("Prefer", "return=representation")] [json| {"due_at": "2019-01-03T11:00:00Z", "smth": "here", "label_color": "invalid", "fake_id": 13} |] `shouldRespondWith` - [json| {"code":"PGRST204","message":"Column 'helicopters' of relation 'datarep_todos' does not exist","details":null,"hint":null} |] + [json| {"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'helicopters' column of 'datarep_todos' in the schema cache"} |] { matchStatus = 400 , matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"] } @@ -969,7 +969,7 @@ spec actualPgVersion = do request methodPatch "/datarep_todos_computed?id=eq.2&columns=label_color,helicopters" [("Prefer", "return=representation")] [json| {"due_at": "2019-01-03T11:00:00Z", "smth": "here", "label_color": "invalid", "fake_id": 13} |] `shouldRespondWith` - [json| {"code":"PGRST204","message":"Column 'helicopters' of relation 'datarep_todos_computed' does not exist","details":null,"hint":null} |] + [json| {"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'helicopters' column of 'datarep_todos_computed' in the schema cache"} |] { matchStatus = 400 , matchHeaders = ["Content-Type" <:> "application/json; charset=utf-8"] }