[Fixed] My code updates the wrong google sheet row (always the first one)

What I’m trying to do:
I am trying to update a cell in a particular row of Google Sheets, however wrongly the first row gets updated. I think this might be a bug (-:
Thanks to everyone who might find any mistake in my approach or maybe confirm that this really wrong (-:

PS:. Anvil is simply wonderful!

What I’ve tried and what’s not working:
I tried this via both the server and client access, but this does not seem to matter.
Please see my images below: In the shared app I am trying to update row no. 4 (a = ‘id’) to change cell of column b to the word update, but after passing the same row the column b, it updates the first row of the sheet.

before clicking

after clicking

See my code below.
I am listing all rows where the column ‘a’ contains the keyword ‘id’. And then I try to update the value of colum b in the same row (by passing the same row). However only the first row gets updated.

Code Sample:

sheet = app_files.anvil_test 
worksheet = sheet['main'] # selects worskheet called main
   rows = ws.list_rows(a='id') # searches for rows containing 'id' in column 'a'
    for row in rows:
      print(row) # to check what the row actually represents
      row['b'] = 'update' # this should update the same row, cell column b, but in reality it updates the very first row.

Clone link:
cloned app

the post has been edited for clarity

Thanks for reporting - looks like a bug when there is a query operator.

Could you check if it runs as expected when you try:

    worksheet = sheet['main']
    rows = worksheet.list_rows()
    for row in rows:
      if row['a'] != 'id':
      row['b'] = 'update'

We’ll get the query operator version fixed and report back

This should now be fixed


Hi @stucork, thanks or the super quick fixing :slight_smile: I can confirm that it is working now as expected :slight_smile:

1 Like