| 262 | } |
| 263 | |
| 264 | func Example_setArrayColumnToEmpty() { |
| 265 | gql := `mutation { |
| 266 | products(where: { id: 100 }, update: { tags: [] }) { |
| 267 | id |
| 268 | tags |
| 269 | } |
| 270 | }` |
| 271 | |
| 272 | conf := newConfig(&core.Config{DBType: dbType, DisableAllowList: true}) |
| 273 | gj, err := core.NewGraphJin(conf, db) |
| 274 | if err != nil { |
| 275 | panic(err) |
| 276 | } |
| 277 | defer gj.Close() |
| 278 | |
| 279 | ctx := context.WithValue(context.Background(), core.UserIDKey, 3) |
| 280 | res, err := gj.GraphQL(ctx, gql, nil, nil) |
| 281 | if err != nil { |
| 282 | logSnowflakeQueryFailure(gj, gql, nil, err) |
| 283 | fmt.Println(err) |
| 284 | } else { |
| 285 | printJSON(res.Data) |
| 286 | } |
| 287 | |
| 288 | // Cleanup: restore tags to original state |
| 289 | _, _ = db.Exec(`UPDATE products SET tags = list_value('Tag 1', 'Tag 2', 'Tag 3', 'Tag 4', 'Tag 5') WHERE id = 100`) |
| 290 | |
| 291 | // Output: {"products":[{"id":100,"tags":[]}]} |
| 292 | } |
| 293 | |
| 294 | func TestMultiAliasUpdate(t *testing.T) { |
| 295 | skipBigQueryMutationsUnsupported(t) |