Open maurerbot opened 8 years ago
I don't know more details about your case, so I can't reproduce it on my local.
But, why you don't declare the jsonObjectMapper
as:
implicit val jsonObjectMapper = MappedColumnType.base[MyJsonObject, JsValue](s => Json.toJson(s),str => Json.fromJson[MyJsonObject](str))
As you know, slick
will generate the option version of the mapper on demand for us.
just drop the optional? I have it optional atm because the aggregate is created first without any data. I think I can work around that and try.
I don't know what exactly happened, so I just pointed out an obviously problem. You can try it first.
If the problem still exists, pls provide more full details, to let me reproduce and deep it.
@adrianmaurer All of the BaseTypedType can not to be Option[_], it's hard code in slick. Because can't read null data in all BaseTypedType. If you defined a Option BaseTypedType slick will always throws a error. Just do as what @tminglei said and slick will auto import a Shape[Rep[Option[MyJsonObject], Option[MyJsonObject], Rep[Option[MyJsonObject]]]]
to you.
I'm trying to build a query that returns a few selected columns using slick-pg for as my slick driver but I'm having issues trying to map on the json column
MyValueObject
. The error I am getting at runtime is...A client error occurred: slick.driver.JdbcTypesComponent$MappedJdbcType$$anon$1 cannot be cast to slick.ast.OptionType"
My case case clase, table mapper, and query looks similar to this...
The only solution I can come up with right now is to map on the result but the returning rows can be very large and I'd like to avoid loading a sequence of large objects into memory.
Is there a way to fix this query?
stackoverflow: http://stackoverflow.com/questions/36703548/slick-query-jsonb-cannot-be-cast-to-slick-ast-optiontype