]> source.dussan.org Git - jackcess.git/commitdiff
use actual implicit comp op subclass
authorJames Ahlborn <jtahlborn@yahoo.com>
Sat, 29 Apr 2017 19:56:14 +0000 (19:56 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Sat, 29 Apr 2017 19:56:14 +0000 (19:56 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1091 f203690c-595d-4dc9-a70b-905162fa7fd2

src/main/java/com/healthmarketscience/jackcess/impl/expr/Expressionator.java
src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java

index 29bb7e129cd7e716cc345f1aa728abe33d55cf4f..7eaea7a667e7cc66e31ee42870b5f2b9ae0ed5bd 100644 (file)
@@ -421,7 +421,7 @@ public class Expressionator
       // a non-conditional expression for a FIELD_VALIDATOR treats the result
       // as an equality comparison with the field in question.  so, transform
       // the expression accordingly
-      expr = new ECompOp(CompOp.EQ, THIS_COL_VALUE, expr);
+      expr = new EImplicitCompOp(expr);
     }
 
     return (expr.isConstant() ?
@@ -1700,6 +1700,24 @@ public class Expressionator
     }
   }
 
+  private static class EImplicitCompOp extends ECompOp
+  {
+    private EImplicitCompOp(Expr right) {
+      super(CompOp.EQ, THIS_COL_VALUE, right);
+    }
+
+    @Override
+    protected void toExprString(StringBuilder sb, boolean isDebug) {
+      // only output the full "implicit" comparison in debug mode
+      if(isDebug) {
+        super.toExprString(sb, isDebug);
+      } else {
+        // just output the explicit part of the expression
+        _right.toString(sb, isDebug);
+      } 
+    }    
+  }
+
   private static class ELogicalOp extends EBaseBinaryOp
   {
     private ELogicalOp(LogOp op, Expr left, Expr right) {
index 4efcedbd75d22eea2b39aafbae11042df78e4f3f..9bc7f4982f345dc36fe962f9e4227f40a6517806 100644 (file)
@@ -297,7 +297,13 @@ public class ExpressionatorTest extends TestCase
                                    String cleanStr) {
     Expression expr = Expressionator.parse(
         Expressionator.Type.FIELD_VALIDATOR, exprStr, null);
-    assertEquals(debugStr, expr.toDebugString());
+    String foundDebugStr = expr.toDebugString();
+    if(foundDebugStr.startsWith("<EImplicitCompOp>")) {
+      assertEquals("<EImplicitCompOp>{<EThisValue>{<THIS_COL>} = " + 
+                   debugStr + "}", foundDebugStr);
+    } else {
+      assertEquals(debugStr, foundDebugStr);
+    }
     assertEquals(cleanStr, expr.toString());
   }