Had a few days off lately, hence the recent radio silence :) Latest update is that I've ported across all the grammar tests that Fabio had in the Artorius project and added them to the ANTLR- HQL.Tests project. The way I've done this is a smidge twisted, and I'm not sure that I particularly like the implementation, but it is working. What I've done is:
* Moved all the various queries from the original Artorius C# file (GrammarFixture.cs, for those interested) and dumped them into an XML file in the ANTLR project (TestQueries.xml). I've preserved names, comments etc as far as possible * Written a small Java console app to consume that XML file, run each query against Hibernate, and create a new XML file (TestQueriesWithResults.xml) which includes a string representation of the AST tree that Hibernate built * Moved the ANTLR-HQL.Tests project to use NUnit 2.5, and created a data driven test which spins round the XML file, pushing each query into the new parser and checking that the tree created matches the Hibernate results. This has resulted in 816 tests, all of which now pass against the latest ANTLR-HQL checkin. So I'm pretty confident that the first pass of the HQL parser is in pretty good shape. Next step is do start getting tests running against the second pass... One interesting thing is that out of the original Artorius tests, there are a number of queries that don't parse in Hibernate. I've dumped these below, and would appreciate feedback from you chaps as to which of these should work in the NHibernate world, and which can be removed: select bar.string, foo.string from bar in class org.hibernate.test.Bar inner join bar.baz as baz inner join elements(baz.fooSet) as foo where baz.name = 'name' select bar.string, foo.string from bar in class org.hibernate.test.Bar, bar.baz as baz, elements(baz.fooSet) as foo where baz.name = 'name' select count(*) where this.amount>-1 and this.name is null from sm in class org.hibernate.test.SubMulti where exists sm.children.elements from Order order where maxindex(order.items) > 100 from Order order where minelement(order.items) > 10000 select item from Item item, Order order where order.items[ maxindex (order.items) ] = item and order.id = 11 select bar.string, foo.string from bar in class org.hibernate.test.Bar inner join bar.baz as baz inner join elements(baz.fooSet) as foo where baz.name = 'name' select bar.string, foo.string from bar in class org.hibernate.test.Bar, bar.baz as baz, elements(baz.fooSet) as foo where baz.name = 'name' select count(*) where this.amount>-1 and this.name is null from sm in class org.hibernate.test.SubMulti where exists sm.children.elements from Order order join order.group select count(a.id) from Animal a having count(a.id)>1 select avg(a.BodyWeight) from Animal a having avg(a.BodyWeight)>0 select max(a.BodyWeight) from Animal a having max(a.BodyWeight)>0 select min(a.BodyWeight) from Animal a having min(a.BodyWeight)>0 select sum(a.BodyWeight) from Animal a having sum(a.BodyWeight)>0 select cast(cast(cast(a.BodyWeight as string) as double) as int from Animal a group by cast(cast(cast(a.BodyWeight as string) as double) as int having cast(cast(cast(a.BodyWeight as string) as double) as int = 1 Cheers, Steve
