Setting multiple fields when updating an array not working

I was trying to run the following query:

UPDATE b4tPools USE KEYS 'bet365’
SET sheet.inProgress = true,
sheet.submittedBy = ‘timTest’,
sheet.submissionDate = '14/10/2017’
FOR sheet IN pools.weekly2017.week6 WHEN sheet.id = 1507971053000 END

It is properly finding the item in the array but only the last item - in this case sheet.submissionDate - is getting set. I tried changing the order and it was always the last item getting set.

It all works fine if I break it into 3 separate queries, but I don’t see why the above doesn’t work

Thanks

each SET clause needs its own FOR. https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/update.html

UPDATE b4tPools USE KEYS 'bet365’
SET sheet.inProgress = true FOR sheet IN pools.weekly2017.week6 WHEN sheet.id = 1507971053000 END,
sheet.submittedBy = 'timTest' FOR sheet IN pools.weekly2017.week6 WHEN sheet.id = 1507971053000 END,
sheet.submissionDate = '14/10/2017' FOR sheet IN pools.weekly2017.week6 WHEN sheet.id = 1507971053000 END;
1 Like

Thanks - this makes sense. I was thinking of it as a WHERE clause kind of thing, but each SET has it’s own FOR