typhon-project / typhonql

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

[BUG] selecting all fields of an entity having relationships #92

Closed meuriceloup closed 3 years ago

meuriceloup commented 4 years ago

Hey guys,

This is my ML schema:

entity "product" {
   "internal_code" : bigint
   "label" : string[50]
   "vat" : float
   "orders" -> "orders"[0..*]
}

entity "orders" {
   "accountnumber" : string[30]
   "price" : float
   "orderdate" : date
   "customer" -> "customer"[1]
   "product" -> "product"."product.orders"[0..*]
}

entity "employee" {
   "firstname" : string[100]
   "lastname" : string[50]
   "employee" -> "employee"[0..1]
   "employee_1" -> "employee"."employee.employee"[0..*]
}

entity "customer" {
   "firstname" : string[100]
   "lastname" : string[100]
   "orders" -> "orders"."orders.customer"[0..*]
}

relationaldb RelationalDatabase {
   tables {
      table {
         "product" : "product"
         idSpec ("product.internal_code")
      }
      table {
         "orders" : "orders"
      }
      table {
         "employee" : "employee"
      }
      table {
         "customer" : "customer"
      }
   }
}

documentdb DocumentDatabase {
}

After having executed the "resetdatabases" operation, my user db is deployed and empty (no data). I then tried to execute the following query: from orders o select o

but the ql engine returned this error:

typhonql-server_1           | )
typhonql-server_1           | TyphonQL failed to handle request, msg:
typhonql-server_1           | Could not find source tbl for outer join: o with as("orders.product-product.orders","junction_product$1") on equ(column("junction_product$1","orders.product"),column("o","orders.@id"))
typhonql-server_1           | Trace:
typhonql-server_1           | |lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(4398,2,<138,79>,<138,81>): "Could not find source tbl for outer join: o with as(\"orders.product-product.orders\",\"junction_product$1\") on equ(column(\"junction_product$1\",\"orders.product\"),column(\"o\",\"orders.@id\"))"
typhonql-server_1           |   at addLeftOuterJoin(|lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(4056,349,<130,2>,<139,3>))
typhonql-server_1           |   at expr2sql(|lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(9582,176,<318,4>,<320,86>))
typhonql-server_1           |   at recordResults(|lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(6088,52,<210,11>,<210,63>))
typhonql-server_1           |   at select2sql(|lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(6915,17,<238,8>,<238,25>))
typhonql-server_1           |   at compile2sql(|lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(2571,130,<89,0>,<90,35>))
typhonql-server_1           |   at compileQuery(|lib://typhonql/src/lang/typhonql/Query2Script.rsc|(3259,21,<95,22>,<95,43>))
typhonql-server_1           |   at request2script(|lib://typhonql/src/lang/typhonql/Request2Script.rsc|(2543,5,<82,22>,<82,27>))
typhonql-server_1           |   at runScriptForQuery(|lib://typhonql/src/lang/typhonql/RunUsingCompiler.rsc|(2995,34,<90,8>,<90,42>))
typhonql-server_1           |   at runQueryAndGetJava(|lib://typhonql/src/lang/typhonql/RunUsingCompiler.rsc|(3438,46,<104,1>,<104,47>))
typhonql-server_1           |   at runQueryAndGetJava(|lib://typhonql/src/lang/typhonql/RunUsingCompiler.rsc|(6403,47,<186,9>,<186,56>))
typhonql-server_1           |   at lang::typhonql::RunUsingCompiler(|main://lang::typhonql::RunUsingCompiler|10:29:22.640 [qtp485937598-19] ERROR engineering.swat.typhonql.server.QLRestServer - Failed to handle response
typhonql-server_1           | org.rascalmpl.interpreter.control_exceptions.Throw: |lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|:138,79: "Could not find source tbl for outer join: o with as(\"orders.product-product.orders\",\"junction_product$1\") on equ(column(\"junction_product$1\",\"orders.product\"),column(\"o\",\"orders.@id\"))"
typhonql-server_1           |   at org.rascalmpl.interpreter.control_exceptions.ControlException.reallyFillInStackTrace(ControlException.java:42) ~[rascal-0.18.2.jar:?]

The same happens when I select all from entity employee... This error is probably due to the way the QL engine deals with the relationships.

Thanks in advance ;-)

tvdstorm commented 3 years ago

Fixed in 6d0d6d93bfa0ed28d1732690f228e7752badcba2