Fix location header for inserted objects with nulls
This commit is contained in:
@@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### Added
|
||||
- Option to specify nulls first or last, eg `/people?order=age.desc.nullsfirst`
|
||||
- Filter nulls, `?col=is.null` and `?col=isnot.null`
|
||||
### Fixed
|
||||
- Allow NULL values in posts
|
||||
|
||||
## [0.2.7.0] - 2015-03-03
|
||||
### Added
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ app v1schema reqBody req =
|
||||
then inserted
|
||||
else filterWithKey (const . (`elem` primaryKeys)) inserted
|
||||
let params = urlEncodeVars
|
||||
$ map (\t -> (cs $ fst t, "eq." <> cs (unquoted $ snd t)))
|
||||
$ map (\t -> (cs $ fst t, cs (paramFilter $ snd t)))
|
||||
$ sortBy (comparing fst) $ toList primaries
|
||||
return $ responseLBS status201
|
||||
[ jsonH
|
||||
|
||||
@@ -237,3 +237,7 @@ unquoted _ = ""
|
||||
insertableValue :: JSON.Value -> T.Text
|
||||
insertableValue JSON.Null = "null"
|
||||
insertableValue v = ((<> "::unknown") . pgFmtLit . unquoted) v
|
||||
|
||||
paramFilter :: JSON.Value -> T.Text
|
||||
paramFilter JSON.Null = "is.null"
|
||||
paramFilter v = "eq." <> unquoted v
|
||||
|
||||
@@ -69,9 +69,11 @@ spec = afterAll_ resetDb $ around withApp $ do
|
||||
it "can post nulls" $ do
|
||||
p <- request methodPost "/no_pk"
|
||||
[("Prefer", "return=representation")]
|
||||
[json| { "a":null, "b":null } |]
|
||||
liftIO $
|
||||
simpleBody p `shouldBe` [json| { "a":null, "b":null } |]
|
||||
[json| { "a":null, "b":"foo" } |]
|
||||
liftIO $ do
|
||||
simpleBody p `shouldBe` [json| { "a":null, "b":"foo" } |]
|
||||
simpleHeaders p `shouldSatisfy` matchHeader hLocation "/no_pk\\?a=is.null&b=eq.foo"
|
||||
simpleStatus p `shouldBe` created201
|
||||
|
||||
context "with compound pk supplied" . after_ (clearTable "compound_pk") $
|
||||
it "builds response location header appropriately" $
|
||||
|
||||
Reference in New Issue
Block a user