typhon-project / typhonql

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

[BUG] Delete using a field in the clause is not working #78

Closed zolotas4 closed 4 years ago

zolotas4 commented 4 years ago

Describe the bug

I have a Category element in the database with name "cat 1" and @id "#eec1c111-69e8-40c9-a1a4-092f918a595c". I need to delete this element using name field as filter in the where clause. The query throws an error. If I try to delete using the @id in the clause, deletion works. I execute the commands through the REST API.

Query

delete Category c where c.name == "cat 1"

Model

ML: here

Expected behavior

I expect the element named "cat 1" to be deleted.

zolotas4 commented 4 years ago

I confirm that this is now working with the latest version. So, I close the issue.

zolotas4 commented 4 years ago

Sorry, bad testing form my side. I tested from Category c select c where c.name == "cat 1" and not the original query delete Category c where c.name == "cat 1" which was not working and still doesn't work.

tvdstorm commented 4 years ago

@pinoval this is related to MongoDB deletion (deleteMany needs to be supported).

zolotas4 commented 4 years ago

I don't know if that helps but I also tested this on an entity in a relational DB (i.e., CreditCard in the ML above). It doesn't work too. The error I get is the following:

select `cc`.`CreditCard.@id` as `cc.CreditCard.@id` 
typhonql-server             | from `CreditCard` as `cc`
typhonql-server             | where (`cc`.`CreditCard.number`) = ('3529-2930-4919-1213');
typhonql-server             | delete from `CreditCard` 
typhonql-server             | where (`CreditCard`.`CreditCard.@id`) = (${param_3});
typhonql-server             | unknown location: IllegalArgument("field(RelationalDatabase, cc, CreditCard, @id)","Results was null for field field(RelationalDatabase, cc, CreditCard, @id) and store RESULTSTORE({})")
typhonql-server             | 13:28:54.143 [qtp1116094714-21] ERROR engineering.swat.typhonql.server.QLRestServer - Failed to handle response
typhonql-server             | org.rascalmpl.interpreter.control_exceptions.Throw: IllegalArgument("field(RelationalDatabase, cc, CreditCard, @id)","Results was null for field field(RelationalDatabase, cc, CreditCard, @id) and store RESULTSTORE({})")
typhonql-server             |   at org.rascalmpl.interpreter.control_exceptions.ControlException.reallyFillInStackTrace(ControlException.java:42) ~[rascal-0.17.0.jar:?]

The same problem exists with update commands, too (both mongo and maria).

tvdstorm commented 4 years ago

This should work now, as confirmed by dbdf68b77058776ec2da2c26eccc6fab1bb73f9c.