aquariumbio / pydent

Scripting APIs for Aquarium
http://aquariumbio.github.io/trident
MIT License
6 stars 2 forks source link

Model.last() returns list #86

Open dvnstrcklnd opened 3 years ago

dvnstrcklnd commented 3 years ago

The Model.last() method returns a list. It seems like it should return a single object.

last_sample = session.Sample.last()
print("{}: {}".format(last_sample.name, last_sample.description))

produces

Traceback (most recent call last):
  File "load_samples.py", line 11, in <module>
    print("{}: {}".format(last_sample.name, last_sample.description))
AttributeError: 'list' object has no attribute 'name'
cashmonger commented 3 years ago

I would also expect Model.last to return a single object. I can change things so it does, but, in the interim, there is also a "one" method you can call that will return the last item.

last_sample = session.Sample.one()
print("{}: {}".format(last_sample.name, last_sample.description))
GS apater F: subpool adapter with linker for Agilent libraries
jvrana commented 3 years ago

The way it is now, .last(n) was intended to always return a list, but it doesn't have to be that way, so it may make sense to change it to