You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Andrey Mashenkov <am...@gridgain.com> on 2016/11/30 14:55:51 UTC

SQL: Table aliases not supported for SqlQuery

Hi Igniters,

H2Indexing.generateQuery() generates wrong sql query. It is used in
SqlQuery class for queries like this:
     new SqlQuery(Person.class. "from Person p where p.salary > ? and
p.salary <= ?")
This query produce next sql query string:
    "SELECT "".Person._key, ""Person"._val FROM Person p where p.salary > ?
and p.salary <= ?"
We should use table alias instead on table name in "SELECT" query part. It
looks like we can't automatically determine correct alias, as we can have
multiple aliases for one table or even subquery in "FROM" part.

The solution is to provide table alias SqlQuery object to generate correct
query. SqlQuery is ignite public class.

Is it ok, if I add new constructor in SqlQuery class?

Re: SQL: Table aliases not supported for SqlQuery

Posted by Sergi Vladykin <se...@gmail.com>.
I don't mind to have an alias in SqlQuery, but it is better to add setter
method setAlias instead of having an additional constructor with signature
(String,String,String).

Sergi

2016-11-30 17:55 GMT+03:00 Andrey Mashenkov <am...@gridgain.com>:

> Hi Igniters,
>
> H2Indexing.generateQuery() generates wrong sql query. It is used in
> SqlQuery class for queries like this:
>      new SqlQuery(Person.class. "from Person p where p.salary > ? and
> p.salary <= ?")
> This query produce next sql query string:
>     "SELECT "".Person._key, ""Person"._val FROM Person p where p.salary > ?
> and p.salary <= ?"
> We should use table alias instead on table name in "SELECT" query part. It
> looks like we can't automatically determine correct alias, as we can have
> multiple aliases for one table or even subquery in "FROM" part.
>
> The solution is to provide table alias SqlQuery object to generate correct
> query. SqlQuery is ignite public class.
>
> Is it ok, if I add new constructor in SqlQuery class?
>