What is the type of starting_row in FieldType.row_of_dependency_updated ? I see TableModelQuerySet, list, or single row

I’m putting together a sample baserow plugin which introduces new FieldTypes. The API is well documented (comments on class FieldType in baserow), but one thing eludes me: what is the type of starting_row in FieldType.row_of_dependency_updated ?

seems like I have to do the following to cover all use cases:

        if isinstance(starting_row, TableModelQuerySet):
            # if starting_row is TableModelQuerySet (when creating multiple rows in a batch), we want to iterate over its TableModel objects
            row_list = starting_row
        elif isinstance(starting_row, list):
            # if we have a list, it's a list of TableModels, iterate over them
            row_list = starting_row            
        else:
            # we got a single TableModel, transform it into a list of one element
            row_list = [starting_row]

is this the right way to implement row_of_dependency_updated ? or am I doing something wrong ? Disclaimer: i’m a Django noob but I plan on remedying this soon.

Hey @lucw

So i’m not sure Baserow’s internals ever actually use this parameter. I found its type definition here:

StartingRowType = Union["GeneratedTableModel", List["GeneratedTableModel"]]

So from the typing level it should be either one row instance, or a list of row instances.

After looking at it however, it looks like as you point out we never pass in a List["GeneratedTableModel"] but instead a queryset of all the updated rows in the RowHandler.update_rows function.

Given this I think your code to handle this is sensible, and agree Baserow should just always pass a list as a nice to have refactor.

OK great thanks, i’ll leave it like that !