edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Scoping issue when not using closure in `update`

Open colinhacks opened this issue 3 years ago • 0 comments

const query = e
    .insert(e.Movie, {
      title: "Harry Potter",
      rating: 5,
    })
    .unlessConflict(movie => ({
      on: movie.title,
      else: e.update(movie, () => ({
        set: {
          rating: e.op(movie.rating, "+", 1),
        },
      })),
    }));

results in the following query

INSERT default::Movie {
  title := "Harry Potter",
  rating := 5
} 
UNLESS CONFLICT ON default::Movie.title
ELSE ((WITH
  __scope_0_Movie := default::Movie
UPDATE __scope_0_Movie SET {
  rating := (DETACHED default::Movie.rating + 1)
}))

colinhacks avatar Aug 09 '22 04:08 colinhacks