typhon-project / typhonql

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

QL insert: cannot retrieve the generated UUID #25

Closed meuriceloup closed 4 years ago

meuriceloup commented 4 years ago

Hi,

When we execute insert queries through the web service, e.g., insert User {, name: "test", surname: "test" }, we receive this kind of response "{ "response": "Query response: 1" }", indicating if the insert is a success (or not).

However, it would be interesting if the web service could return (in addition to the operation success) the UUID generated and attached to this new inserted user. This way, we could directly retrieve the uuid and exploit it (for instance, to link other objects to the user).

At this moment, the only way to retrieve the inserted client's uuid is to execute a select query based on the primary key value, just after the insert... what can provoke slownesses.

Would it be possible to improve it? Thank you, Loup

pinoval commented 4 years ago

We have augmented the API to support this (mainly commits 477e97db96449fb62b29420ea69697f91be1fddd and 8bd4025a6d94e341257a78deb9c4c167bda18858).

Now every update operation returns a pair of two values: an integer (intended as the number of affected entities) and a map from labels to uuids. The labels are automatically created if not indicated in the query, but the recommended use would be:

insert @user1 User { name: "test", surname: "test" }

Then, for example, the returned value would be something like:

{ 1, { "user1" : "4142be7a-e549-4e10-92e0-ca5f9925e839"}}

Using labels allow us to clearly see which uuids were created for the inserted entities.