Better treatment when adding a Container as a parent.
I tried the following with a recent "dev" pylib and the indiscale demo server:
import caosdb as db
rt = db.execute_query("Find RecordType violin")
ntest = db.Record(name="ntest")
ntest.add_parent(rt)
ntest.insert()
leads to:
TransactionError: TransactionError: One or more entities are not qualified. None of them have been inserted/updated/deleted.
+--| REASONS |--
| -> RECORD (id: -1, name: 'ntest') CAUSED |UnqualifiedParentsError: Entity has unqualified parents.
| +--| REASONS |--
| | -> PARENT (id: None, name: '<Entities>
<noscript>
</noscript>
<RecordType id="109" name="Violin">
<Version id="41f12af91b375d351cecb29089e582e4ece38210" head="true">
<Predecessor id="5b10293da7264781f3a1c684502710d5b322abc4"/>
</Version>
<Parent id="108" name="MusicalInstrument" flag="inheritance:OBLIGATORY,"/>
<Property id="100" name="price" datatype="DOUBLE" unit="€" importance="RECOMMENDED" flag="inheritance:FIX"/>
<Property id="107" name="Manufacturer" description="A generic manufacturer of all kinds of products" datatype="Manufacturer" importance="RECOMMENDED" flag="inheritance:FIX"/>
</RecordType>
</Entities>
') CAUSED | |EntityDoesNotExistError: Entity does not exist.
| +----------------
+----------------
Also, the object ntest
looks broken:
In [2]: ntest
Out[2]:
<Record id="-1" cuid="-1--9e6c237b-b19d-4397-b3b7-88e01a9df40e" name="ntest">
<Error code="116" description="Entity has unqualified parents."/>
<Warning code="0" description="Entity has no properties."/>
<Parent name="<Entities> <noscript> </noscript> <RecordType id="109" name="Violin"> <Version id="41f12af91b375d351cecb29089e582e4ece38210" head="true"> <Predecessor id="5b10293da7264781f3a1c684502710d5b322abc4"/> </Version> <Parent id="108" name="MusicalInstrument" flag="inheritance:OBLIGATORY,"/> <Property id="100" name="price" datatype="DOUBLE" unit="€" importance="RECOMMENDED" flag="inheritance:FIX"/> <Property id="107" name="Manufacturer" description="A generic manufacturer of all kinds of products" datatype="Manufacturer" importance="RECOMMENDED" flag="inheritance:FIX"/> </RecordType> </Entities> "/>
</Record>
There is a suspicious "" in the server response. Might that be the cause?