Hi Artem,
On Aug 22, 2008, at 1:37 AM, Artem Melentyev wrote:
  Hi, devs.
 I would like to discuss about the new xwiki query language.
 
http://dev.xwiki.org/xwiki/bin/view/Design/XWikiQueryLanguage
 We need to choose a syntax and data model of the query language
 There are some examples in
 
http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificati…
 I already have a prototype based on my JPQL parser (SableCC based 
Is that a good parser generator? I know JavaCC and Antlr but have
never used SableCC. I'm just worried about us having different parser
generators so if we choose one we should try to continue using it
across our modules as much as possible. Right now my preference would
go to javacc or antlr since they're more well known. Ideally antlr is
by far the most powerful but I think it may also be the most complex
to use unfortunately.
  ) and
 hql generator. It is quite easy to modify syntax and generator.
 Results
 of my query parser research in the end of the message.
 I propose:
 0) Name: XWiki Query Language, XWQL as a name of the new language. 
+0, I don't have a preference.
  1) Data Model: Choose query method #1 from
specification
 
http://dev.xwiki.org/xwiki/bin/view/Design/XWiki+Query+Language+Specificati…
 with corrections:
 add Document as a virtual class for our XWikiDocument.
 use "docalias.XWiki.ClassName instead" of "XWiki.ClassName".
 docalias is
 some alias for Document.
 add optional select clause.
 example:
 "select doc.fullName
  from Document as doc, doc.XWiki.XWikiUsers as user
  where user.email like '%xwiki.com' and  doc.author=:username"
 "select doc.fullName from Document as doc" may be omitted. It will be
 added if there is no Document in query statement. So "from
 doc.XWiki.XWikiUsers as user" is correct query statement. 
I don't like the mix of semantics between doc.fullName for example
(which represents a property of a document - a field in the DB) and
doc.XWiki.XWikiUsers which represents an object of a document. I don't
think they should be at the same level and the usage of "." in the
object name is confusing (and may also confuse the parser).
I'd prefer something like: doc.objects(XWiki.XWikiUsers) or
doc.objects("XWiki.XWikiUsers").
Then we can add: doc.attachment(attachmentName) and doc.class later on.
WDYT?
  It is possible to use several documents and objects in
one query.
 Attachment, Class, and other xwiki entities will be added later if
 needed.
 2) Syntax: XWQL will be JPQL subset.
  (hint: JPQL is part of Java Persistance API standard, JSR#317. HQL is
 a superset of JPQL. Hibernate support JPA)
  All JPQL features and all hibernate data model will be accessible for
 hibernate store. But it is not true for JCR store.
  Only described data model will be available for XWQL on JCRStore.
 (But
 we may add some extensions later)
  In JCRv2 will not work (JCRSQL2 constraint):
   arithmetic expressions (+-*/)
   aggregation funtions (max,min,sum,avg)
   some other functions
  In JCRv1 also will not work (XPath constraint):
   query on several documents (from Document as doc1, Document as doc2)
  Some JPQL limitations compared with HQL:
   no arithmetic expressions (+-*/) in select clause
   aliases at from clause are mandatory (from Document as alias)
 So the main idea is to use simple JPQL preprocessor to rewrite virtual
 data model to real.
 This is quite easy for HQL and JCRSQL2. But it is hard(but doable) for
 JCRv1 XPath. 
I don't know enough to be able to say anything intelligent on this
topic...
Sounds good otherwise.
Thanks
-Vincent