MCPcopy Index your code
hub / github.com/dosco/graphjin / Example_setArrayColumnToEmpty

Function Example_setArrayColumnToEmpty

tests/update_test.go:264–292  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

262}
263
264func 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
294func TestMultiAliasUpdate(t *testing.T) {
295 skipBigQueryMutationsUnsupported(t)

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
GraphQLMethod · 0.95
newConfigFunction · 0.85
logSnowflakeQueryFailureFunction · 0.85
printJSONFunction · 0.85
ExecMethod · 0.65

Tested by

no test coverage detected