metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Balendra Singh <balendrasi...@gmail.com>
Subject Re: Nested INNER query is not supported
Date Wed, 23 Apr 2014 07:26:41 GMT
Hi,

Code that was mentioned in the screenshot, has been pasted below.
In this code, I wanted to show that in QueryParser.parse() method, we are
fetching the *FROM *clause to parse it.
To fetch the FROM clause , it is calling *getNextStartIndex()* and if
*_queryString* contains a nested inner query then it gets a invalid
*FROM *clause
and throws exception.

*public Query parse() throws QueryParserException {*
*        final Query query = new Query();*

*        // collect focal point query clauses*
*        int[] selectIndices = indexesOf("SELECT ", null);*
*        int[] fromIndices = indexesOf(" FROM ", selectIndices);*
*        int[] whereIndices = indexesOf(" WHERE ", fromIndices);*
*        int[] groupByIndices = indexesOf(" GROUP BY ", whereIndices);*
*        int[] havingIndices = indexesOf(" HAVING ", groupByIndices);*
*        int[] orderByIndices = indexesOf(" ORDER BY", havingIndices);*
*        int[] limitIndices = indexesOf(" LIMIT ", orderByIndices);*
*        int[] offsetIndices = indexesOf(" OFFSET ", limitIndices);*

*        // a few validations, minimum requirements*
*        if (selectIndices == null) {*
*            throw new QueryParserException("SELECT not found in query: " +
_queryString);*
*        }*
*        if (fromIndices == null) {*
*            throw new QueryParserException("FROM not found in query: " +
_queryString);*
*        }*

*        // parse FROM*
*        {*
*            final String fromClause = getSubstring(*
*                    getLastEndIndex(fromIndices),*
*                    getNextStartIndex(whereIndices, groupByIndices,
havingIndices, orderByIndices, limitIndices,*
*                            offsetIndices));*
*            parseFromClause(query, fromClause);*
*        }*



Thanks,
Balendra




On 19 April 2014 15:47, Kasper Sørensen <i.am.kasper.sorensen@gmail.com>wrote:

> Attachments doesnt work in the mailing lists AFAIK. So svare it via a JIRA
> attachment or upload it somewhere and provide a link.
> Den 16/04/2014 08.06 skrev "Henry Saputra" <henry.saputra@gmail.com>:
>
> > Sorry Balendra, I do not see the attachment, anyone else saw it?
> >
> > Not sure if the mailing list drop the attachment or my gmail setting
> >
> > - Henry
> >
> >
> > On Tue, Apr 15, 2014 at 10:36 PM, Balendra Singh
> > <balendrasingh@gmail.com> wrote:
> > > Hi Henry,
> > >
> > > Attaching the image again.
> > >
> > >
> > >
> > > Thanks,
> > > Balenrdra
> > >
> > >
> > >
> > > On 15 April 2014 23:14, Henry Saputra <henry.saputra@gmail.com> wrote:
> > >>
> > >> Hi Balendra,
> > >>
> > >> Hmm, seems like the image is not included in the mail to mailing list.
> > >> Could you try to add it as attachment or link to external URL?
> > >>
> > >> - Henry
> > >>
> > >>
> > >> On Tue, Apr 15, 2014 at 3:14 AM, Balendra Singh
> > >> <balendrasingh@gmail.com>wrote:
> > >>
> > >> > I have a use-case in which I have to write a query having nested
> INNER
> > >> > JOIN. Using Metamodel Api, we can write the query but while
> execution,
> > >> > it
> > >> > is throwing following exception-
> > >> >
> > >> > *org.eobjects.metamodel.query.parser.QueryParserException: Not
> capable
> > >> > of
> > >> > parsing FROM token.*
> > >>
> > >> >
> > >> > It is throwing exception as in QueryParser.parse() function, it is
> > >> > trying
> > >> > to fetch the from clause without considering that it can also have
> the
> > >> > nested inner query as mentioned in the following screenshot -
> > >> >
> > >> > [image: Inline images 1]
> > >> >
> > >> > *Although <query>.toSql() is returning a valid query*.
> > >>
> > >> >
> > >> > So now I am trying to write query without nested inner query. If
> this
> > is
> > >> > a
> > >> > valid use-case so there should be provision to write it.
> > >> >
> > >> >
> > >> >
> > >> > Thanks,
> > >> > Balendra
> > >> >
> > >> >
> > >> >
> > >> >
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message