usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject usergrid git commit: Fix in UnionScanColumn comparator fixes order or operations error https://issues.apache.org/jira/browse/USERGRID-1099
Date Thu, 05 Nov 2015 18:58:11 GMT
Repository: usergrid
Updated Branches:
  refs/heads/usergrid-1099 [created] c776a2fb3


Fix in UnionScanColumn comparator fixes order or operations error https://issues.apache.org/jira/browse/USERGRID-1099


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/c776a2fb
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c776a2fb
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c776a2fb

Branch: refs/heads/usergrid-1099
Commit: c776a2fb34d76f5cd779009a200ab8cf1e288b5d
Parents: 0706444
Author: Dave Johnson <snoopdave@apache.org>
Authored: Thu Nov 5 13:58:07 2015 -0500
Committer: Dave Johnson <snoopdave@apache.org>
Committed: Thu Nov 5 13:58:07 2015 -0500

----------------------------------------------------------------------
 .../query/ir/result/AbstractScanColumn.java     |  2 +-
 .../query/ir/result/UnionIterator.java          |  6 +-
 .../persistence/ParenthesisProblemIT.java       | 79 ++++++++++++++++++++
 3 files changed, 83 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/c776a2fb/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumn.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumn.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumn.java
index cabb710..f99103c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumn.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/AbstractScanColumn.java
@@ -69,7 +69,7 @@ public abstract class AbstractScanColumn implements ScanColumn {
 
         ScanColumn that = ( ScanColumn ) o;
 
-        return uuid.equals( that.getUUID() );
+        return getUUID().equals( that.getUUID() );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c776a2fb/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/UnionIterator.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/UnionIterator.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/UnionIterator.java
index 526fced..3f786f8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/UnionIterator.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/query/ir/result/UnionIterator.java
@@ -264,13 +264,13 @@ public class UnionIterator extends MultiIterator {
             if ( this == o ) {
                 return true;
             }
-            if ( !( o instanceof UnionScanColumn ) ) {
+            if ( !( o instanceof ScanColumn ) ) {
                 return false;
             }
 
-            final UnionScanColumn that = ( UnionScanColumn ) o;
+            final ScanColumn that = ( ScanColumn ) o;
 
-            return delegate.getUUID().equals( that.delegate.getUUID() );
+            return getUUID().equals( that.getUUID() );
         }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/c776a2fb/stack/core/src/test/java/org/apache/usergrid/persistence/ParenthesisProblemIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/ParenthesisProblemIT.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/ParenthesisProblemIT.java
new file mode 100644
index 0000000..ab52416
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/ParenthesisProblemIT.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.persistence;
+
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.usergrid.AbstractCoreIT;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+
+
+public class ParenthesisProblemIT extends AbstractCoreIT {
+    private static final Logger logger = LoggerFactory.getLogger( ParenthesisProblemIT.class
);
+
+    @Test // this test passes
+    public void parenthesisProblem1() throws Exception {
+        // C = c and ( A > a or B = false )
+        parenthesisProblem(1, "color = 'tabby' and (age > 7 or large = true)");
+    }
+    
+    @Test // this test fails
+    public void parenthesisProblem2() throws Exception {
+        // same as #1 except for order of things listed in 'and' operation
+        // ( A > a or B = false ) and C = c
+        parenthesisProblem(1, "select * where (age > 7 or large = true) and color = 'tabby'");
+    }
+
+    private void parenthesisProblem( int expect, String query ) throws Exception {
+        UUID applicationId = setup.createApplication(
+                "testOrganization", "parenthesisProblem_" + RandomStringUtils.randomAlphanumeric(10));
+        EntityManager em = setup.getEmf().getEntityManager( applicationId );
+
+        em.create( "cat", new HashMap<String, Object>() {{
+            put("name","enzo");
+            put("color","orange");
+            put("large", true);
+            put("age",6);
+        }});
+
+        em.create( "cat", new HashMap<String, Object> () {{
+            put("name","marquee");
+            put("color","grey");
+            put("large",false);
+            put("age",8);
+        }});
+
+        em.create( "cat", new HashMap<String, Object> () {{
+            put("name","bertha");
+            put("color","tabby");
+            put("large",true);
+            put("age",1);
+        }});
+
+        final Results entities = em.searchCollection(
+                new SimpleEntityRef("application", applicationId), "cats", Query.fromQL(query));
+        
+        assertEquals(expect, entities.size());
+    }
+}


Mime
View raw message