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
multiset
support similar to jOOQ.Proposed Additions
JsonValue
newtype wrapper with a SqlSelect based on JSON parsingto_json
onSqlExpr (Value a)
andSqlExpr (Entity a)
and tuples (up to 8?)Value a
is trivially implemented using the built into_json
Entity a
can use theentityDef
tojson_build_object
assuming that theFieldDef.fieldHaskell
matches the default persistentjson
json_build_array
json_agg :: SqlExpr (JsonValue a) -> SqlExpr (JsonValue [a])
this is limited toJsonValue
to enforce the use of ourto_json
implementation instead of relying on the default postgres behavior.