As a user I would like to be able to extract JSON values from a query. This would be useful for faking multiset support similar to jOOQ.
Proposed Additions
- Add a new
JsonValue newtype wrapper with a SqlSelect based on JSON parsing
- Add support for
to_json on SqlExpr (Value a) and SqlExpr (Entity a) and tuples (up to 8?)
Value a is trivially implemented using the built in to_json
Entity a can use the entityDef to json_build_object assuming that the FieldDef.fieldHaskell matches the default persistent json
- Tuples can be represented using
json_build_array
- Add support for
json_agg :: SqlExpr (JsonValue a) -> SqlExpr (JsonValue [a]) this is limited to JsonValue to enforce the use of our to_json implementation instead of relying on the default postgres behavior.
As a user I would like to be able to extract JSON values from a query. This would be useful for faking
multisetsupport similar to jOOQ.Proposed Additions
JsonValuenewtype wrapper with a SqlSelect based on JSON parsingto_jsononSqlExpr (Value a)andSqlExpr (Entity a)and tuples (up to 8?)Value ais trivially implemented using the built into_jsonEntity acan use theentityDeftojson_build_objectassuming that theFieldDef.fieldHaskellmatches the default persistentjsonjson_build_arrayjson_agg :: SqlExpr (JsonValue a) -> SqlExpr (JsonValue [a])this is limited toJsonValueto enforce the use of ourto_jsonimplementation instead of relying on the default postgres behavior.