Chain of Reference (List)s causing #AttributeError

EDIT: Well. This is a bug only on the desktop app. I’m guessing it was just fixed in the most recent update?


Hello!

Not sure if this is a bug or not so I’m asking here before GitHub just in case I’ve missed something.

I’m developing a database of chemistry information. The latest table has a formula containing a long chain of references:

Element ← Cation ← Binary Compound (list) ← Mixed Compound (list) ←Mixed Compound (formula)

(Where Cation contains a reference column to Element, etc.)

In the formula I’m trying to get the column “Name” from Element through the column “Compound List” in Mixed Compound with:

$Compound_List.Cation.Element.Name

but this causes:

AttributeError : ‘list’ object has no attribute ‘Element’

$Compound_List.Cation.Element of course gives the same error. Only $Compound_List.Cation returns anything, which is [Cation[[23]], Cation[[94]]. Which is what it should look like, no? So why isn’t it working?

Thanks for all you do :slight_smile:

There was indeed a recent fix to this (Several improvements to RecordSet handling. by dsagal · Pull Request #1992 · gristlabs/grist-core · GitHub), which probably hasn’t made it into Grist-Desktop yet.

You can still get what you want though, you’d just need to use a bit more Python. The issue is that $Compound_List is a reference list, and $Compound_List.Cation is a helper to get the list of item.Cation for each item of $Compound_List. Until the recent change, that was just a regular Python list. You should be able to get a list of Element.Name from it with

[c.Element.Name for c in $Compound_List.Cation]

That should work before and after the change. After the change $Compound_List.Cation.Element.Name should produce the same members (but possibly remove duplicates, tbh I don’t remember if it would).