Skip to content

can't figure out how to use CTE and values #131

Closed Answered by stephenafamo
gstarikov asked this question in Q&A
Discussion options

You must be logged in to vote

The main reason why this is not possible is that Bob currently does not yet have a way to build VALUES queries. Only SELECT, UPDATE, INSERT and DELETE.

Since we already have the syntax down for inserts, I could try and make this work 🤔 .

In the meantime, here is a way you can do this, relying on clause.Values

vals := clause.Values{}
vals.AppendValues(psql.S("1"), psql.S("data 1"))
vals.AppendValues(psql.S("2"), psql.S("data 2"))
vals.AppendValues(psql.S("3"), psql.S("data 3"))

psql.Update(
  um.With("c", "id", "data").As(bob.BaseQuery[clause.Values]{
    Expression: vals,
    Dialect: dialect.Dialect,
  }),
  um.TableAs("test", "t"),
  um.Set("data").To("c.data"),
  um.From("c"),
  um.Where

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@gstarikov
Comment options

@stephenafamo
Comment options

@gstarikov
Comment options

@gstarikov
Comment options

@stephenafamo
Comment options

Answer selected by stephenafamo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants