brj 2005/01/14 12:49:42
Modified: src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
QueryTest.java
Log:
added testcase for attributes in expressions (price + 1.0)
Revision Changes Path
No revision
No revision
1.61.2.8 +21 -0 db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
Index: QueryTest.java
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
retrieving revision 1.61.2.7
retrieving revision 1.61.2.8
diff -u -r1.61.2.7 -r1.61.2.8
--- QueryTest.java 12 Dec 2004 01:35:12 -0000 1.61.2.7
+++ QueryTest.java 14 Jan 2005 20:49:41 -0000 1.61.2.8
@@ -11,6 +11,7 @@
import java.util.Vector;
import org.apache.commons.lang.time.StopWatch;
+import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
import org.apache.ojb.broker.metadata.ClassDescriptor;
import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
import org.apache.ojb.broker.query.Criteria;
@@ -1542,6 +1543,26 @@
// Groups: 3 Books , 1 Dairy Product
assertEquals("check size", list.size(), 2);
}
+
+ /**
+ * ReportQuery with Expression in column need to add table alias to the
field (price)
+ **/
+ public void testReportQueryExpressionInStatement()
+ {
+ // TODO: make path expressions extent aware
+ if(ojbSkipKnownIssueProblem("Resolve attributes of expressions"))
return;
+
+ Criteria crit = new Criteria();
+ ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class,
crit);
+ q.setAttributes(new String[]{"articleId", "price + 0"});
+ ClassDescriptor cd = broker.getClassDescriptor(q.getBaseClass());
+ SqlGenerator sqlg = broker.serviceSqlGenerator();
+ String sql = sqlg.getPreparedSelectStatement(q, cd);
+
+ assertTrue("Bad query generated. the 'price' field has not table
prefix. SQL Output: " + sql, sql
+ .equalsIgnoreCase("SELECT A0.Artikel_Nr,A0.PRICE + 0 FROM
Artikel A0"));
+ }
+
/**
* Test pathExpression and Extents
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]