typhon-project / typhonql

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

Failed to properly declare the polystore id column in a request #88

Closed Stratidakos closed 4 years ago

Stratidakos commented 4 years ago

Hello. I encountered a 500 Server Error, when I tried to execute a POST request (Batch update). So, we have two entities, OBLG_GNL and OBLG_DTL, and a relation between them named, CUST_DTL from OBLG_GNL's side and CUST_GNL from OBLG_DTL's side. I used the OBLG_GNL's polystore id to update the CUST_DTL field. The polystore id of the entity in the MariaDB is named "OBLG_GNL.@id". Here are the failed request attempts.

1) {"command":"update OBLG_GNL{id:??id,CUST_DTL:??CUST_DTL}","parameterNames":["id","CUST_DTL"],"boundRows":[["\"321b7db8-5bab-49bb-97bf-e402cfa2e458\"","\"acb1af91-282c-45bb-bb89-34355b6a8cec\""],["\"368dd077-1719-4a7e-8add-688b7db949e9\"","\"f6925a2f-23e5-47ce-989c-dedefb8a3f08\""]]}

2) {"command":"update OBLG_GNL{id:??id,CUST_DTL:??CUST_DTL}","parameterNames":["id","CUST_DTL"],"boundRows":[["#321b7db8-5bab-49bb-97bf-e402cfa2e458","\"acb1af91-282c-45bb-bb89-34355b6a8cec\""],["#368dd077-1719-4a7e-8add-688b7db949e9","\"f6925a2f-23e5-47ce-989c-dedefb8a3f08\""]]}

3) {"command":"update OBLG_GNL{id:??id,CUST_DTL:??CUST_DTL}","parameterNames":["id","CUST_DTL"],"boundRows":[["#321b7db8-5bab-49bb-97bf-e402cfa2e458","acb1af91-282c-45bb-bb89-34355b6a8cec"],["#368dd077-1719-4a7e-8add-688b7db949e9","f6925a2f-23e5-47ce-989c-dedefb8a3f08"]]}

Which is the correct way to declare the polystore id column? Thank you for your time.

DavyLandman commented 4 years ago

All ids/refs have to be a uuid, so with a # in front.

Could you also post the error message printed in the ql container (docker-compose logs typhonql-server)

DavyLandman commented 4 years ago

I think this should be the right command:

{
   "command": "update OBLG_GNL{@id:??id, CUST_DTL:??CUST_DTL}",
   "parameterNames": ["id", "CUST_DTL"],
   "boundRows": [
        ["#321b7db8-5bab-49bb-97bf-e402cfa2e458", "#acb1af91-282c-45bb-bb89-34355b6a8cec"],
        ["#368dd077-1719-4a7e-8add-688b7db949e9", "#f6925a2f-23e5-47ce-989c-dedefb8a3f08"]
   ]
}
  1. id should be @id (it's a special field)
  2. id values should be encoded as a ql literal.
  3. it's always a good idea to try out a query in the IDE, it gives you much more feedback on problems than the API
DavyLandman commented 4 years ago

Closing it, discussed offline that the update syntax is different than the insert syntax.

it should be:

{
   "command": "update OBLG_GNL o where o.@id == ??id set {CUST_DTL:??CUST_DTL}",
   "parameterNames": ["id", "CUST_DTL"],
   "boundRows": [
        ["#321b7db8-5bab-49bb-97bf-e402cfa2e458", "#acb1af91-282c-45bb-bb89-34355b6a8cec"],
        ["#368dd077-1719-4a7e-8add-688b7db949e9", "#f6925a2f-23e5-47ce-989c-dedefb8a3f08"]
   ]
}