Skip to content
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

How to update filed in jsonb and other columns in one call #543

Open
slovvik opened this issue Mar 9, 2022 · 0 comments
Open

How to update filed in jsonb and other columns in one call #543

slovvik opened this issue Mar 9, 2022 · 0 comments

Comments

@slovvik
Copy link

slovvik commented Mar 9, 2022

I have faced a problem in that I can only update the JSON column in my object and can't update other columns.

Let say I have this table definition:

class JsonTestTable(tag: Tag) extends Table[JsonBean](tag, "JsonTest0") {
    def id = column[Long]("id", O.AutoInc, O.PrimaryKey)
    def test = column[String]("test")
    def json = column[JsonString]("json", O.Default(JsonString(""" {"a":"v1","b":2} """)))

    def * = (id, json) <> (JsonBean.tupled, JsonBean.unapply)
  }

and want to update the JSON column and the test column in one query. How should I do that?
I stuck with this:

JsonTests.filter(_.id === 33L).map(o => (o.test, o.json.set(List("c"), JsonString(""" [1] """)))).update(("newValue", "sameAsParameterInSetMethod?"))

but this makes non sens and returns

A query for an UPDATE statement must select table columns only -- Unsupported shape: ProductNode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant