Skip to content

Missing datatype leads to error

Suppose the RecordTypes Dataset and Subject exist. If you try to insert a Record with multiple references without appropriate type, the following happens:

In [10]: print(db.Record().add_parent("Dataset").add_property("Subject", [181,183]).insert())

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/CaosDB/caosdb-pylib/src/caosdb/common/models.py:1379, in _parse_value(datatype, value)
   1378 try:
-> 1379     return int(value)
   1380 except ValueError:
   1381     # reference via name

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'

[...]

ServerConfigurationException: The server sent an invalid XML: List valued properties must be announced by the datatype.
Datatype: Subject
value: ['122', '222']

However, with the appropriate datatype, this works: db.Record().add_parent("Dataset").add_property("Subject", [181,183], datatype=db.LIST("Subject")).insert()

Thus, when the crawler creates Properties with list values, the datatype needs to be set appropriately. This is currently not the case. See ab4a98f8

Edited by Henrik tom Wörden