typhon-project / typhonql

Typhon Query Language
Eclipse Public License 2.0
4 stars 1 forks source link

[BUG] containment in sql not working #106

Closed barmpis closed 3 years ago

barmpis commented 3 years ago

Describe the bug

Trying to add a containment reference in mysql results in the reference to not be added (remains null with the relevant entity never created)

Query

{
"query" : "insert Datatypes {cref: CRefer {r: 3}}"
}

Model

entity Datatypes {
    cref :-> CRefer[1]
}

entity CRefer {
    r : int
}

 relationaldb DatatypesDB {
    tables { 
        table{
            DatatypesTable : Datatypes
            }
        table{
            CReferTable : CRefer
            }           
    } 
 }

Expected behavior

Expected a Datatypes entity to be created with a contained CRefer entity, the reference remains null instead.

tvdstorm commented 3 years ago

Support for the nested object literals in inserts has been indefinitely postponed AFAIK. The way to do this is: first create the CRefer, get its uuid, and then assign it to cref (i.e. by reference).

barmpis commented 3 years ago

that is impossible, containments cannot be created on their own (used to just do nothing but now throws exception)

edit: the exception is in mysql, in a document store i am unsure if it still does nothing (aka pretends the entity is inserted and gives its uuid but in the store nothing is there) or also throws an exception. This is regarding trying to create a new entity like CRefer on its own.

tvdstorm commented 3 years ago

Ok, I will have a look.

tvdstorm commented 3 years ago

Hi, I've looked our tests (where it works). Can you try the following:

First add an inverse on the child (CRefer):

datatype -> Datatypes."Datatypes.cref"[1]

And then insert the CRefer after inserting a Datatypes (the parent), like so:

insert CRefer { r: 123, datatype: #...theuuid }
barmpis commented 3 years ago

thank you, it works with inclusion of an inverse.