-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter Optional JSONB columns mapped to CustomType #486
Comments
@lakshmankollipara here's the codes of trait PlayJsonImplicits extends PlayJsonCodeGenSupport {
import utils.JsonUtils.clean
implicit val playJsonTypeMapper: JdbcType[JsValue] =
new GenericJdbcType[JsValue](
pgjson,
(v) => Json.parse(v),
(v) => clean(Json.stringify(v)),
hasLiteralForm = false
)
implicit def playJsonColumnExtensionMethods(c: Rep[JsValue]) = {
new JsonColumnExtensionMethods[JsValue, JsValue](c)
}
implicit def playJsonOptionColumnExtensionMethods(c: Rep[Option[JsValue]]) = {
new JsonColumnExtensionMethods[JsValue, Option[JsValue]](c)
}
} Here, the points are So to support implicit def myClass JsonColumnExtensionMethods(c: Rep[MyClass]) = {
new JsonColumnExtensionMethods[MyClass, MyClass](c)
}
implicit def myClass JsonOptionColumnExtensionMethods(c: Rep[Option[MyClass]]) = {
new JsonColumnExtensionMethods[MyClass, Option[MyClass]](c)
} I didn't test it. But you can give it a try. |
Hi, @tminglei just tried but didn't succeed:
and definitions:
would like to run query like this: Where that |
@1gorsh this part of your definitions implicit def vectorOfAddressesColumnExtensionMethods(c: Rep[Vector[Address]]): JsonColumnExtensionMethods[Address, Vector[Address]] = {
new JsonColumnExtensionMethods[Address, Vector[Address]](c)
} is wrong. It should be implicit def vectorOfAddressesColumnExtensionMethods(c: Rep[Vector[Address]]): JsonColumnExtensionMethods[Address, Vector[Address]] = {
new JsonColumnExtensionMethods[Vector[Address], Vector[Address]](c)
} |
Hi, @tminglei |
@1gorsh ok! 😄 |
I have an optional(nullable) JSONB column which is mapped to Scala Case class.
def myColumn: Rep[MyClass] = column[MyClass]("my_column")
Implicit mapping looks like:
How can I filter based on json keys inside "myColumn" column?
Obviously this didn't work:
TableQuery[MyTable].filter(_.myColumn +> "boolean" === true)
The text was updated successfully, but these errors were encountered: