Hi Balendra, Interesting case. I think we should be able to produce a test case for this quite simply. Would be nice to first reproduce it in QueryParserTest (I see some tests of subquery parsing, but not subquery with a join) and then we can fix it.
Best regards, Kasper 2014-04-23 9:26 GMT+02:00 Balendra Singh <[email protected]>: > 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 <[email protected] > >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" <[email protected]>: > > > > > 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 > > > <[email protected]> wrote: > > > > Hi Henry, > > > > > > > > Attaching the image again. > > > > > > > > > > > > > > > > Thanks, > > > > Balenrdra > > > > > > > > > > > > > > > > On 15 April 2014 23:14, Henry Saputra <[email protected]> > 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 > > > >> <[email protected]>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 > > > >> > > > > >> > > > > >> > > > > >> > > > > > > > > > > > > > > >
