JSON addition to Database.Persist.Postgresql#793
JSON addition to Database.Persist.Postgresql#793MaxGabriel merged 11 commits intoyesodweb:masterfrom Vlix:master
Conversation
… and new Filter operators (@>.) and (<@.)
MaxGabriel
left a comment
There was a problem hiding this comment.
Thanks for writing such detailed documentation, strong 👍. I had a few comments:
- The Haddocks aren't rendering how I think you want them to
- Could you update the
persistent-postgresql/Changelog.mdfile with a link to your PR? - Would it be possible to write a test for this? It could be scoped to just Postgres using the preprocessor
ifdefs the test suite already uses. This isn't essential but would be quite nice
| -- null @> 23 --> False | ||
| -- null @> "null" --> False | ||
| -- null @> {} --> False | ||
| -- @ |
| -- Any empty Object matches any object | ||
| -- @ | ||
| -- {"a":1,"b":false} @> {} --> True | ||
| -- @ |
There was a problem hiding this comment.
This documentation has quite a few examples, and I think if formatted correctly would be pretty huge. My default would be to hide them in an ==== __Examples__ collapsible section, but it might be OK since this module is quite small
| (@>.) :: EntityField record Value -> Value -> Filter record | ||
| (@>.) field val = Filter field (Left val) $ BackendSpecificFilter " @> " | ||
|
|
||
| -- | Same as `(<@.)` except the inclusion check is reversed. |
There was a problem hiding this comment.
I think you want single quotes, not backticks, for that
| case eitherDecodeStrict bs of | ||
| Left str -> Left $ fromPersistValueParseError "FromJSON" bs $ T.pack str | ||
| Right v -> Right v | ||
| fromPersistValueJsonB x = Left $ fromPersistValueError "FromJSON" "string or bytestring" x |
There was a problem hiding this comment.
Instead of bytestring, could you use a database name like Postgres' bytea?
* Upgraded the randomValues function in DataTestTypes.hs to actually have random values everytime * small OCD
…work because of it
|
Updated a lot. Should also pass all tests. |
|
Thanks for your work on this! Great patch; really like the documentation with all the examples, and the copious tests. I've merged and released on Hackage 👍 |

Added
PersistFieldandPersistFieldSqlinstances forData.Aeson.Valueand newFilteroperators(@>.)and(<@.)that work withValue.