@@ -3,6 +3,10 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
## unreleased
|
||||||
|
|
||||||
|
- Allow nested objects and arrays in JSON post for jsonb columns
|
||||||
|
|
||||||
## [0.2.8.0] - 2015-04-17
|
## [0.2.8.0] - 2015-04-17
|
||||||
### Added
|
### Added
|
||||||
- Option to specify nulls first or last, eg `/people?order=age.desc.nullsfirst`
|
- Option to specify nulls first or last, eg `/people?order=age.desc.nullsfirst`
|
||||||
|
|||||||
+1
-1
@@ -268,7 +268,7 @@ unquoted (JSON.String t) = t
|
|||||||
unquoted (JSON.Number n) =
|
unquoted (JSON.Number n) =
|
||||||
cs $ formatScientific Fixed (if isInteger n then Just 0 else Nothing) n
|
cs $ formatScientific Fixed (if isInteger n then Just 0 else Nothing) n
|
||||||
unquoted (JSON.Bool b) = cs . show $ b
|
unquoted (JSON.Bool b) = cs . show $ b
|
||||||
unquoted _ = ""
|
unquoted v = cs $ JSON.encode v
|
||||||
|
|
||||||
insertableText :: T.Text -> T.Text
|
insertableText :: T.Text -> T.Text
|
||||||
insertableText = (<> "::unknown") . pgFmtLit
|
insertableText = (<> "::unknown") . pgFmtLit
|
||||||
|
|||||||
@@ -94,6 +94,22 @@ spec = afterAll_ resetDb $ around withApp $ do
|
|||||||
, matchHeaders = []
|
, matchHeaders = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context "jsonb" . after_ (clearTable "json") $ do
|
||||||
|
it "serializes nested object" $ do
|
||||||
|
let inserted = [json| { "data": { "foo":"bar" } } |]
|
||||||
|
p <- request methodPost "json" [("Prefer", "return=representation")] inserted
|
||||||
|
liftIO $ do
|
||||||
|
simpleBody p `shouldBe` inserted
|
||||||
|
simpleHeaders p `shouldSatisfy` matchHeader hLocation "/json\\?data=eq\\.%7B%22foo%22%3A%22bar%22%7D"
|
||||||
|
simpleStatus p `shouldBe` created201
|
||||||
|
it "serializes nested array" $ do
|
||||||
|
let inserted = [json| { "data": [1,2,3] } |]
|
||||||
|
p <- request methodPost "json" [("Prefer", "return=representation")] inserted
|
||||||
|
liftIO $ do
|
||||||
|
simpleBody p `shouldBe` inserted
|
||||||
|
simpleHeaders p `shouldSatisfy` matchHeader hLocation "/json\\?data=eq\\.%5B1%2C2%2C3%5D"
|
||||||
|
simpleStatus p `shouldBe` created201
|
||||||
|
|
||||||
describe "CSV insert" $ do
|
describe "CSV insert" $ do
|
||||||
|
|
||||||
after_ (clearTable "menagerie") . context "disparate csv types" $
|
after_ (clearTable "menagerie") . context "disparate csv types" $
|
||||||
|
|||||||
Reference in New Issue
Block a user