jochen 2005/03/02 07:13:43
Modified: src/js/org/apache/ws/jaxme/sqls/impl SQLGeneratorImpl.java
BooleanConstraintImpl.java StatementMetaData.java
PartsImpl.java FunctionImpl.java
ObjectFactoryImpl.java
src/js/org/apache/ws/jaxme/sqls BooleanConstraint.java
Parts.java ObjectFactory.java
src/js/org/apache/ws/jaxme/sqls/junit CreateTest.java
Added: src/js/org/apache/ws/jaxme/sqls/impl ExpressionImpl.java
src/js/org/apache/ws/jaxme/sqls Expression.java
Log:
Added support for arithmetic expressions.
Revision Changes Path
1.27 +45 -1
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SQLGeneratorImpl.java
Index: SQLGeneratorImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/SQLGeneratorImpl.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- SQLGeneratorImpl.java 2 Mar 2005 13:35:32 -0000 1.26
+++ SQLGeneratorImpl.java 2 Mar 2005 15:13:42 -0000 1.27
@@ -30,6 +30,7 @@
import org.apache.ws.jaxme.sqls.CombinedConstraint;
import org.apache.ws.jaxme.sqls.Constraint;
import org.apache.ws.jaxme.sqls.DeleteStatement;
+import org.apache.ws.jaxme.sqls.Expression;
import org.apache.ws.jaxme.sqls.ForeignKey;
import org.apache.ws.jaxme.sqls.Function;
import org.apache.ws.jaxme.sqls.Index;
@@ -675,11 +676,54 @@
return getFunction(pData, (Function) o);
} else if (o instanceof Case) {
return getCase(pData, (Case) o);
+ } else if (o instanceof Expression) {
+ return getExpression(pData, (Expression) o);
} else {
throw new IllegalArgumentException("Invalid part of a boolean
constraint: " + o.getClass().getName());
}
}
-
+
+ protected String getExpression(StatementMetaData pData, Expression
pExpr) {
+ int parts = pExpr.getNumParts();
+ int minParts = pExpr.getMinimumParts();
+ if (parts < minParts) {
+ throw new IllegalStateException("An expression of type
" + pExpr.getType()
+
+ " must have at least " + minParts + " parts.");
+ }
+ int maxParts = pExpr.getMaximumParts();
+ if (maxParts > 0 && parts > maxParts) {
+ throw new IllegalStateException("An expression of type
" + pExpr.getType()
+
+ " must have at least " + maxParts + " parts.");
+ }
+ Iterator iter = pExpr.getParts();
+ if (parts == 1) {
+ return getBooleanConstraintPart(pData, iter.next());
+ } else {
+ String sep;
+ Expression.Type type = pExpr.getType();
+ if (Expression.SUM.equals(type)) {
+ sep = "+";
+ } else if (Expression.PRODUCT.equals(type)) {
+ sep = "*";
+ } else if (Expression.DIFFERENCE.equals(type)) {
+ sep = "-";
+ } else if (Expression.QUOTIENT.equals(type)) {
+ sep = "/";
+ } else {
+ throw new IllegalStateException("Invalid type:
" + type);
+ }
+ StringBuffer result = new StringBuffer("(");
+ for (int i = 0; i < parts; i++) {
+ if (i > 0) {
+ result.append(sep);
+ }
+ result.append(getBooleanConstraintPart(pData,
iter.next()));
+ }
+ result.append(")");
+ return result.toString();
+ }
+ }
+
protected String getBooleanConstraintType(BooleanConstraint.Type pType) {
if (BooleanConstraint.Type.EQ.equals(pType)) {
return "=";
1.6 +49 -21
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/BooleanConstraintImpl.java
Index: BooleanConstraintImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/BooleanConstraintImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BooleanConstraintImpl.java 2 Mar 2005 13:35:32 -0000 1.5
+++ BooleanConstraintImpl.java 2 Mar 2005 15:13:42 -0000 1.6
@@ -25,27 +25,32 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public class BooleanConstraintImpl extends PartsImpl implements
BooleanConstraint {
- public static class TypeImpl extends SQLFactoryImpl.IdentImpl implements
BooleanConstraint.Type {
- public TypeImpl(String pName) {
- super(pName);
- }
- }
-
- private BooleanConstraint.Type type;
-
- protected BooleanConstraintImpl(CombinedConstraint pCombinedConstraint,
- BooleanConstraint.Type pType) {
- super(pCombinedConstraint.getConstrainedStatement());
- if (pType == null) {
- throw new NullPointerException("The type must not be null.");
- }
- type = pType;
+ /** Default implementation of [EMAIL PROTECTED] BooleanConstraint.Type}.
+ */
+ public static class TypeImpl extends SQLFactoryImpl.IdentImpl
implements BooleanConstraint.Type {
+ private static final long serialVersionUID =
3762254145096135991L;
+ /** Creates a new instance with the given name.
+ */
+ public TypeImpl(String pName) {
+ super(pName);
+ }
}
-
+
+ private BooleanConstraint.Type type;
+
+ protected BooleanConstraintImpl(CombinedConstraint pCombinedConstraint,
+ BooleanConstraint.Type pType) {
+ super(pCombinedConstraint.getConstrainedStatement());
+ if (pType == null) {
+ throw new NullPointerException("The type must not be
null.");
+ }
+ type = pType;
+ }
+
public BooleanConstraint.Type getType() {
- return type;
+ return type;
}
-
+
protected void add(Object pPart) {
Type type = getType();
if (BooleanConstraint.Type.IN.equals(type)) {
@@ -68,8 +73,31 @@
}
super.add(pPart);
}
+
+ public ConstrainedStatement getConstrainedStatement() {
+ return (ConstrainedStatement) getStatement();
+ }
+
+ public int getMinimumParts() { return 1; }
- public ConstrainedStatement getConstrainedStatement() {
- return (ConstrainedStatement) getStatement();
- }
+ public int getMaximumParts() {
+ if (BooleanConstraint.Type.IN.equals(type)) {
+ return 0;
+ } else if (BooleanConstraint.Type.EXISTS.equals(type)
+ ||
BooleanConstraint.Type.ISNULL.equals(type)) {
+ return 1;
+ } else if (BooleanConstraint.Type.BETWEEN.equals(type)) {
+ return 3;
+ } else if (BooleanConstraint.Type.EQ.equals(type)
+ || BooleanConstraint.Type.NE.equals(type)
+ || BooleanConstraint.Type.GT.equals(type)
+ || BooleanConstraint.Type.LT.equals(type)
+ || BooleanConstraint.Type.GE.equals(type)
+ || BooleanConstraint.Type.LE.equals(type)
+ ||
BooleanConstraint.Type.LIKE.equals(type)) {
+ return 2;
+ } else {
+ throw new IllegalStateException("Invalid type: " +
type);
+ }
+ }
}
1.7 +3 -0
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/StatementMetaData.java
Index: StatementMetaData.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/StatementMetaData.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StatementMetaData.java 2 Mar 2005 13:35:32 -0000 1.6
+++ StatementMetaData.java 2 Mar 2005 15:13:42 -0000 1.7
@@ -28,6 +28,7 @@
import org.apache.ws.jaxme.sqls.ColumnReference;
import org.apache.ws.jaxme.sqls.CombinedConstraint;
import org.apache.ws.jaxme.sqls.DeleteStatement;
+import org.apache.ws.jaxme.sqls.Expression;
import org.apache.ws.jaxme.sqls.Function;
import org.apache.ws.jaxme.sqls.InsertStatement;
import org.apache.ws.jaxme.sqls.JoinReference;
@@ -185,6 +186,8 @@
addCombinedConstraint((CombinedConstraint) pPart);
} else if (pPart instanceof Function) {
addParts((Function) pPart);
+ } else if (pPart instanceof Expression) {
+ addParts((Expression) pPart);
} else if (pPart instanceof ColumnReference
|| pPart instanceof Value
|| pPart instanceof RawSQLCode) {
1.4 +19 -0
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/PartsImpl.java
Index: PartsImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/PartsImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PartsImpl.java 22 Sep 2004 10:05:53 -0000 1.3
+++ PartsImpl.java 2 Mar 2005 15:13:42 -0000 1.4
@@ -22,6 +22,7 @@
import org.apache.ws.jaxme.sqls.Case;
import org.apache.ws.jaxme.sqls.ColumnReference;
+import org.apache.ws.jaxme.sqls.Expression;
import org.apache.ws.jaxme.sqls.Function;
import org.apache.ws.jaxme.sqls.Parts;
import org.apache.ws.jaxme.sqls.SelectStatement;
@@ -43,6 +44,8 @@
parts.add(o);
}
+ /** Returns the statement, to which the part belongs.
+ */
public Statement getStatement() {
return statement;
}
@@ -120,6 +123,10 @@
add(pFunction);
}
+ public void addPart(Expression pExpression) {
+ add(pExpression);
+ }
+
public void addPlaceholder() {
add(new ValueImpl(Value.Type.PLACEHOLDER, null));
}
@@ -141,4 +148,16 @@
public void addPart(Case pCase) {
add(pCase);
}
+
+ private Expression newExpression(Expression.Type pType) {
+ Statement st = getStatement();
+ Expression result =
st.getSQLFactory().getObjectFactory().createExpression(st, pType);
+ addPart(result);
+ return result;
+ }
+
+ public Expression createSUM() { return newExpression(Expression.SUM); }
+ public Expression createPRODUCT() { return
newExpression(Expression.PRODUCT); }
+ public Expression createDIFFERENCE() { return
newExpression(Expression.DIFFERENCE); }
+ public Expression createQUOTIENT() { return
newExpression(Expression.QUOTIENT); }
}
1.3 +13 -10
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/FunctionImpl.java
Index: FunctionImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/FunctionImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FunctionImpl.java 16 Feb 2004 23:39:49 -0000 1.2
+++ FunctionImpl.java 2 Mar 2005 15:13:43 -0000 1.3
@@ -23,14 +23,17 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public class FunctionImpl extends PartsImpl implements Function {
- final String name;
-
- /** <p>Creates a new instance of FunctionImpl.java.</p>
- */
- protected FunctionImpl(Statement pStatement, String pName) {
- super(pStatement);
- name = pName;
- }
-
- public String getName() { return name; }
+ final String name;
+
+ /** <p>Creates a new instance of FunctionImpl.java.</p>
+ */
+ protected FunctionImpl(Statement pStatement, String pName) {
+ super(pStatement);
+ name = pName;
+ }
+
+ public String getName() { return name; }
+
+ public int getMinimumParts() { return 0; }
+ public int getMaximumParts() { return 0; }
}
1.9 +5 -0
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/ObjectFactoryImpl.java
Index: ObjectFactoryImpl.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/ObjectFactoryImpl.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ObjectFactoryImpl.java 17 Feb 2005 16:07:43 -0000 1.8
+++ ObjectFactoryImpl.java 2 Mar 2005 15:13:43 -0000 1.9
@@ -21,6 +21,7 @@
import org.apache.ws.jaxme.sqls.ColumnReference;
import org.apache.ws.jaxme.sqls.CombinedConstraint;
import org.apache.ws.jaxme.sqls.ConstrainedStatement;
+import org.apache.ws.jaxme.sqls.Expression;
import org.apache.ws.jaxme.sqls.Function;
import org.apache.ws.jaxme.sqls.JoinReference;
import org.apache.ws.jaxme.sqls.ObjectFactory;
@@ -69,4 +70,8 @@
public ColumnReference newColumnReference(TableReference
pTableReference, Column pColumn) {
return new ColumnReferenceImpl(pTableReference, pColumn);
}
+
+ public Expression createExpression(Statement pStatement,
org.apache.ws.jaxme.sqls.Expression.Type pType) {
+ return new ExpressionImpl(pStatement, pType);
+ }
}
1.1
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/impl/ExpressionImpl.java
Index: ExpressionImpl.java
===================================================================
package org.apache.ws.jaxme.sqls.impl;
import org.apache.ws.jaxme.sqls.Expression;
import org.apache.ws.jaxme.sqls.Statement;
/** Default implementation of [EMAIL PROTECTED]
org.apache.ws.jaxme.sqls.Expression}.
*/
public class ExpressionImpl extends PartsImpl implements Expression {
/** Default implementation of [EMAIL PROTECTED] Expression.Type}.
*/
public static class TypeImpl extends SQLFactoryImpl.IdentImpl
implements Expression.Type {
private static final long serialVersionUID =
3834872498671071537L;
/** Creates a new instance with the given name.
*/
public TypeImpl(String pName) {
super(pName);
}
}
private final Type type;
protected ExpressionImpl(Statement pStatement, Expression.Type pType) {
super(pStatement);
type = pType;
}
public Type getType() { return type; }
public int getMinimumParts() { return 1; }
public int getMaximumParts() {
if (Expression.PRODUCT.equals(type)
|| Expression.SUM.equals(type)) {
return 0;
} else if (Expression.DIFFERENCE.equals(type)
|| Expression.QUOTIENT.equals(type)) {
return 2;
} else {
throw new IllegalStateException("Invalid type: " +
type);
}
}
}
1.9 +41 -41
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/BooleanConstraint.java
Index: BooleanConstraint.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/BooleanConstraint.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BooleanConstraint.java 2 Mar 2005 13:35:32 -0000 1.8
+++ BooleanConstraint.java 2 Mar 2005 15:13:43 -0000 1.9
@@ -21,45 +21,45 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Jochen Wiedmann</a>
*/
public interface BooleanConstraint extends Constraint, Parts {
- /** <p>The type of a boolean constraint.</p>
- */
- public interface Type {
- /** A boolean constraint matching the "equal" condition.
- */
- public static final Type EQ = new BooleanConstraintImpl.TypeImpl("EQ");
- /** A boolean constraint matching the "not equal" condition.
- */
- public static final Type NE = new BooleanConstraintImpl.TypeImpl("NE");
- /** A boolean constraint matching the "lower than" condition.
- */
- public static final Type LT = new BooleanConstraintImpl.TypeImpl("LT");
- /** A boolean constraint matching the "greater than" condition.
- */
- public static final Type GT = new BooleanConstraintImpl.TypeImpl("GT");
- /** A boolean constraint matching the "lower or equal" condition.
- */
- public static final Type LE = new BooleanConstraintImpl.TypeImpl("LE");
- /** A boolean constraint matching the "greater or equal" condition.
- */
- public static final Type GE = new BooleanConstraintImpl.TypeImpl("GE");
- /** A boolean constraint matching the "LIKE" condition.
- */
- public static final Type LIKE = new
BooleanConstraintImpl.TypeImpl("LIKE");
- /** A boolean constraint matching the "IS NULL" condition.
- */
- public static final Type ISNULL = new
BooleanConstraintImpl.TypeImpl("ISNULL");
- /** A boolean constraint matching the "IN" condition.
- */
- public static final Type IN = new BooleanConstraintImpl.TypeImpl("IN");
- /** A boolean constraint matching the "EXISTS" condition.
- */
- public static final Type EXISTS = new
BooleanConstraintImpl.TypeImpl("EXISTS");
- /** A boolean constraint matching the "BETWEEN" condition.
- */
- public static final Type BETWEEN = new
BooleanConstraintImpl.TypeImpl("BETWEEN");
- }
-
- /** <p>Returns the boolean constraints type.</p>
- */
- public BooleanConstraint.Type getType();
+ /** <p>The type of a boolean constraint.</p>
+ */
+ public interface Type {
+ /** A boolean constraint matching the "equal" condition.
+ */
+ public static final Type EQ = new
BooleanConstraintImpl.TypeImpl("EQ");
+ /** A boolean constraint matching the "not equal" condition.
+ */
+ public static final Type NE = new
BooleanConstraintImpl.TypeImpl("NE");
+ /** A boolean constraint matching the "lower than" condition.
+ */
+ public static final Type LT = new
BooleanConstraintImpl.TypeImpl("LT");
+ /** A boolean constraint matching the "greater than" condition.
+ */
+ public static final Type GT = new
BooleanConstraintImpl.TypeImpl("GT");
+ /** A boolean constraint matching the "lower or equal"
condition.
+ */
+ public static final Type LE = new
BooleanConstraintImpl.TypeImpl("LE");
+ /** A boolean constraint matching the "greater or equal"
condition.
+ */
+ public static final Type GE = new
BooleanConstraintImpl.TypeImpl("GE");
+ /** A boolean constraint matching the "LIKE" condition.
+ */
+ public static final Type LIKE = new
BooleanConstraintImpl.TypeImpl("LIKE");
+ /** A boolean constraint matching the "IS NULL" condition.
+ */
+ public static final Type ISNULL = new
BooleanConstraintImpl.TypeImpl("ISNULL");
+ /** A boolean constraint matching the "IN" condition.
+ */
+ public static final Type IN = new
BooleanConstraintImpl.TypeImpl("IN");
+ /** A boolean constraint matching the "EXISTS" condition.
+ */
+ public static final Type EXISTS = new
BooleanConstraintImpl.TypeImpl("EXISTS");
+ /** A boolean constraint matching the "BETWEEN" condition.
+ */
+ public static final Type BETWEEN = new
BooleanConstraintImpl.TypeImpl("BETWEEN");
+ }
+
+ /** <p>Returns the boolean constraints type.</p>
+ */
+ public BooleanConstraint.Type getType();
}
1.4 +29 -1 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/Parts.java
Index: Parts.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/Parts.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Parts.java 22 Sep 2004 10:05:53 -0000 1.3
+++ Parts.java 2 Mar 2005 15:13:43 -0000 1.4
@@ -85,6 +85,10 @@
*/
public void addPart(Function pFunction);
+ /** Inserts an arithmetic expression.
+ */
+ public void addPart(Expression pExpression);
+
/** <p>Inserts raw SQL code.</p>
*/
public void addRawSQLPart(String pRawSQL);
@@ -96,8 +100,32 @@
/** <p>Returns the number of parts.</p>
*/
public int getNumParts();
-
+
+ /** Returns the minimum number of parts.
+ */
+ public int getMinimumParts();
+
+ /** Returns the maximum number of parts. Zero indicates unlimited.
+ */
+ public int getMaximumParts();
+
/** <p>Returns an Iterator to the parts that have been added.</p>
*/
public Iterator getParts();
+
+ /** Creates an arithmetic sum.
+ */
+ public Expression createSUM();
+
+ /** Creates an arithmetic product.
+ */
+ public Expression createPRODUCT();
+
+ /** Creates an arithmetic difference.
+ */
+ public Expression createDIFFERENCE();
+
+ /** Creates an arithmetic quotient.
+ */
+ public Expression createQUOTIENT();
}
1.10 +5 -1
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/ObjectFactory.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ObjectFactory.java 17 Feb 2005 16:07:44 -0000 1.9
+++ ObjectFactory.java 2 Mar 2005 15:13:43 -0000 1.10
@@ -15,7 +15,7 @@
*/
package org.apache.ws.jaxme.sqls;
-import org.apache.ws.jaxme.sqls.impl.ColumnReferenceImpl;
+import org.apache.ws.jaxme.sqls.Expression.Type;
/** A factory object for creating all the objects used by
@@ -60,4 +60,8 @@
/** Creates a new instance of [EMAIL PROTECTED] ColumnReference}.
*/
public ColumnReference newColumnReference(TableReference
pTableReference, Column pColumn);
+
+ /** Creates a new instance of [EMAIL PROTECTED] Expression}.
+ */
+ public Expression createExpression(Statement pStatement, Type sum);
}
1.1 ws-jaxme/src/js/org/apache/ws/jaxme/sqls/Expression.java
Index: Expression.java
===================================================================
package org.apache.ws.jaxme.sqls;
import org.apache.ws.jaxme.sqls.impl.ExpressionImpl;
/** Interface of an arithmetic expression.
*/
public interface Expression extends Parts {
/** An expression: The sum of its parts.
*/
public static final Type SUM = new ExpressionImpl.TypeImpl("SUM");
/** An expression: The product of its parts.
*/
public static final Type PRODUCT = new
ExpressionImpl.TypeImpl("PRODUCT");
/** An expression: The difference of its two parts.
*/
public static final Type DIFFERENCE = new
ExpressionImpl.TypeImpl("DIFFERENCE");
/** An expression: The quotient of its two parts.
*/
public static final Type QUOTIENT = new
ExpressionImpl.TypeImpl("QUOTIENT");
/** <p>The type of a boolean constraint.</p>
*/
public interface Type extends SQLFactory.Ident {
}
/** Returns the expression type.
*/
public Type getType();
}
1.12 +19 -0
ws-jaxme/src/js/org/apache/ws/jaxme/sqls/junit/CreateTest.java
Index: CreateTest.java
===================================================================
RCS file:
/home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/sqls/junit/CreateTest.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CreateTest.java 2 Mar 2005 13:35:32 -0000 1.11
+++ CreateTest.java 2 Mar 2005 15:13:43 -0000 1.12
@@ -27,6 +27,7 @@
import org.apache.ws.jaxme.sqls.ColumnReference;
import org.apache.ws.jaxme.sqls.CombinedConstraint;
import org.apache.ws.jaxme.sqls.DeleteStatement;
+import org.apache.ws.jaxme.sqls.Expression;
import org.apache.ws.jaxme.sqls.ForeignKey;
import org.apache.ws.jaxme.sqls.Index;
import org.apache.ws.jaxme.sqls.InsertStatement;
@@ -434,4 +435,22 @@
query = gen.getQuery(selectStatement);
assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable
WHERE (MyName LIKE '%a%' AND (NOT (MyIndex=1 OR MyIndex=2)))", query);
}
+
+ /** Test for expressions.
+ */
+ public void testExpressions() {
+ Table t = getBasicTable();
+ SelectStatement st = t.getSelectStatement();
+ SelectTableReference ref = st.getSelectTableReference();
+ BooleanConstraint bc = st.getWhere().createGT();
+ Expression e1 = bc.createSUM();
+ e1.addPart(ref.newColumnReference("MyIndex"));
+ e1.addPart(3);
+ Expression e2 = bc.createSUM();
+ e2.addPart(5);
+ SQLGenerator gen = getSQLGenerator();
+ String got = gen.getQuery(st);
+ String expect = "SELECT MyIndex, MyName, MyDate FROM
MySchema.MyTable WHERE (MyIndex+3)>5";
+ assertEquals(expect, got);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]