[Python] Modification in rows data since 4.4

Hi everyone,
Here is a little consideration/change/eventually bug I’d like to share with you:
Since v4.4, the data you get while using list_rows function from Python returns every column of your table, even the empty ones. This differs from the JS getRows function which returns only the non-empty columns (and, as far as I remember, from the list_rows return of older version of SeaTable).

See bellow the result of these two functions in a table containing the following columns:

  • Id (text)
  • client (link to other records)
  • client’s rate (link formula/lookup)
  • initial cost (number)
  • cost (formula)
  • my client (text)
  • Try (formula)

Python data :

{'Id': None, 'client': [], "client's rate": [], 'initial cost': None, 'cost': 0, 'Main': [], 'my client': None, 'Try': None, '_locked': None, '_locked_by': None, '_archived': False, '_creator': 'edfefe21cd2641d68b592b5e18a12db4@auth.local', '_ctime': '2024-05-16T14:45:41+02:00', '_last_modifier': 'edfefe21cd2641d68b592b5e18a12db4@auth.local', '_mtime': '2024-05-16T14:45:41+02:00', '_id': 'A3xiWzEtRPycjYZMAMvBrA'}

JS data :

{"_id":"A3xiWzEtRPycjYZMAMvBrA","_mtime":"2024-05-16T12:45:41.829+00:00","_ctime":"2024-05-16T12:45:41.829+00:00","cost":"€0.00"}

As you can see, Python’s list_rows function returns None for most columns, except the link and the link-formula columns where it returns an empty array.

If, like me, you used to test the presence of a piece of data with a simple if 'my_col' in row : (which is probably not the best practice, but used to work), be aware that your test will now always be True.
You’ll have to modify your test like, for example : if 'my_col' in row and row['my_col'] is not None: (except for the links or link-formula columns as seen before).

Where it gets tricky

The case of checkboxes is particular, and you’ll have to pay particular attention in your tests :

  • a checkbox column you never checked (with a standard unchecked default value) will return None
  • a checkbox column that has been checked and then unchecked again will return… False
    A simple if row['checkbox_col'] : or if not row['checkbox_col'] : depending on your needs will do the trick, but still, having two different results for the same piece of data could be a bit confusing…

Sorry, I have no time right now to test if the same happens using the API (probably). With the query function, the behavior seems to be the same however (but I didn’t remember how it worked before v4.4).

Bests,
Benjamin

Dear @bennhatton,

thanks for sharing your observations. It was not our intention to generate breaking changes in the API. Therefore, just some seconds ago, I deactivated the redirect of the calls Get Row and List rows to the new API-Gateway. As a consequence, the API should now behave like it did in the past.

We will re-activate in the future these redirect after we made sure that the output of the API does not create breaking changes.

I am sorry for these changes. Please check your scripts that they work as they should. I keep you updated.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.