| 232 | } |
| 233 | |
| 234 | func Example_setArrayColumnToValue() { |
| 235 | gql := `mutation { |
| 236 | products(where: { id: 100 }, update: { tags: ["super", "great", "wow"] }) { |
| 237 | id |
| 238 | tags |
| 239 | } |
| 240 | }` |
| 241 | |
| 242 | conf := newConfig(&core.Config{DBType: dbType, DisableAllowList: true}) |
| 243 | gj, err := core.NewGraphJin(conf, db) |
| 244 | if err != nil { |
| 245 | panic(err) |
| 246 | } |
| 247 | defer gj.Close() |
| 248 | |
| 249 | ctx := context.WithValue(context.Background(), core.UserIDKey, 3) |
| 250 | res, err := gj.GraphQL(ctx, gql, nil, nil) |
| 251 | if err != nil { |
| 252 | logSnowflakeQueryFailure(gj, gql, nil, err) |
| 253 | fmt.Println(err) |
| 254 | } else { |
| 255 | printJSON(res.Data) |
| 256 | } |
| 257 | |
| 258 | // Cleanup: restore tags to original state |
| 259 | _, _ = db.Exec(`UPDATE products SET tags = list_value('Tag 1', 'Tag 2', 'Tag 3', 'Tag 4', 'Tag 5') WHERE id = 100`) |
| 260 | |
| 261 | // Output: {"products":[{"id":100,"tags":["super","great","wow"]}]} |
| 262 | } |
| 263 | |
| 264 | func Example_setArrayColumnToEmpty() { |
| 265 | gql := `mutation { |