Skip to content

lookupRecords followed by reference returns empty list instead of recordSet #1987

@rambip

Description

@rambip

Describe the current behavior

When the user uses Table.lookupRecords(key=value).ReferencedColumn in a situation where there is no match, the formula returns a list instead ot a RecordSet. This can introduce edge cases that make the python formula fail.

Steps to reproduce

  1. Create a "Rooms" table
  2. Add a column "Name" and add "Room A" and "Room B" items
  3. Create a "Objects" table
  4. Add a column "Name" and a column "Room" that references the first table
  5. Add a single item: a needle in "Room A"
  6. Go back to the "Rooms" table and add a formula column with this content: type(Objects.lookupRecords(Room=$id).Room)
  7. Observe that it is equal to RecordSet for "Room A" and list for "Room B"

Here is the code view:

import grist
from functions import *       # global uppercase functions
import datetime, math, re     # modules commonly needed in formulas


@grist.UserTable
class Objects:
  Name = grist.Text()
  Where = grist.Reference('Rooms')


@grist.UserTable
class Rooms:
  Name = grist.Text()

  def Items(rec, table):
    return None

Describe the expected behavior

The engine should return the same type for both, probably a RecordSet

Where have you encountered this bug?

Instance information (when self-hosting only)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions