typhon-project / typhonql

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

[BUG] #98

Closed zolotas4 closed 3 years ago

zolotas4 commented 3 years ago

Describe the bug

When trying to execute a query "from Product p select p" we get the following error

TyphonQL failed to handle request, msg:
typhonql-server_1           | Could not find source tbl for outer join: p with as("OrderProduct.orders^-Product.orders","junction_orders$1") on equ(column("junction_orders$1","Product.orders"),column("p","Product.@id"))
typhonql-server_1           | Trace:
typhonql-server_1           | |lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(4433,2,<139,79>,<139,81>): "Could not find source tbl for outer join: p with as(\"OrderProduct.orders^-Product.orders\",\"junction_orders$1\") on equ(column(\"junction_orders$1\",\"Product.orders\"),column(\"p\",\"Product.@id\"))"
typhonql-server_1           |   at addLeftOuterJoin(|lib://typhonql/src/lang/typhonql/relational/Query2SQL.rsc|(4091,349,<131,2>,<140,3>))

Query

from Product p select p

Model

entity Review{
    id : string[32] 
    content : string[32] 
    product -> Product[1]
}

entity Product{
    id : string[32]
    name : string[32]
    description : string[32]

    orders -> OrderProduct[0..*]
    review:->Review."Review.product"[0..*]
}

entity OrderProduct{
    id : string[32]
    product_date : datetime
    totalAmount : bigint
    paidWith : string
    products -> Product.products[0..*]
    users -> User."User.orders"[1]

}

entity User{
    id : string[32]
    name : string[32]

    comments : string
    paymentsDetails : string
    orders -> OrderProduct[0..*]
    address -> Address[1]
}

entity Address {
    streetName: string[32]
    streetNumber: bigint
    zipcode: string[32]
    city: string[32]
    country: string[32]
    user -> User."User.address"[1]
}

relationaldb RelationalDatabase{
    tables{
        table {
            OrderDB : OrderProduct
            index orderIndex {
                attributes (id)
            }
            idSpec (id)
        }
        table {
            UserDB : User
            index  userIndex{
                attributes (name)
                }
            idSpec (name)
        }
        table {
            AddressDB : Address
        }
        table {
            ProductDB : Product
            index productIndex{
                attributes (name)
            }
            idSpec (name)
        }

    }
}

documentdb DocumentDatabase{
    collections{
            ReviewDB : Review
    }
}

This is on a standard Docker deployment as it is generated from DL with default values

Expected behavior

A list of all the inserted Products, or empty if no product was inserted before

REST API

{ "query" : "from Product p select p" }

meuriceloup commented 3 years ago

I have the same problems. It could be a critical problem since we have a demo planned on October 19 for the MoDELS conference

DavyLandman commented 3 years ago

I fear this is indeed the same as issue #92

DavyLandman commented 3 years ago

We will do our best to fix this before 19th of October (we have a few other bugs to fix first).

But as a work around, manually select the fields you want.

meuriceloup commented 3 years ago

Yes you're right Davy. A workaround (until this bug will be fixed) is to specify the entity attributes in the select query:' 'from User u select u' crashes, 'from User u select u.name' works

zolotas4 commented 3 years ago

Ok thanks. I will close this issue.