You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/08/05 01:19:44 UTC

[1/2] incubator-usergrid git commit: Added test proving issue.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-903 [created] 0a78e1544


Added test proving issue.


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

Branch: refs/heads/USERGRID-903
Commit: c6f1dbe3c2f562c184abaec128972242366c6542
Parents: 6b90b66
Author: GERey <gr...@apigee.com>
Authored: Tue Aug 4 12:55:21 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Tue Aug 4 12:55:21 2015 -0700

----------------------------------------------------------------------
 .../rest/applications/queries/OrderByTest.java     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c6f1dbe3/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index 99a2a77..2a16d96 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -60,6 +60,23 @@ public class OrderByTest extends QueryTestBase {
         }
     }
 
+    @Test
+    public void testValueWithSpaceAtEndStillQueryable() throws IOException {
+        String collectionName = "stuff";
+        Entity lowerCaseEntity = new Entity();
+        lowerCaseEntity.put( "name","thing1" );
+        lowerCaseEntity.put( "random","fury " );
+
+        this.app().collection( collectionName ).post( lowerCaseEntity );
+
+        refreshIndex();
+
+        QueryParameters params = new QueryParameters()
+            .setQuery("select * where random = 'fury' ");
+        Collection activities = this.app().collection(collectionName).get(params);
+        assertEquals(1, activities.getResponse().getEntityCount());
+        assertEquals( "fury",activities.getResponse().getEntities().get( 0 ).get( "random" ) );
+    }
 
     /**
      * Test correct sort order for Long properties


[2/2] incubator-usergrid git commit: Changed the test to verify that we filter out values that aren't exactly the same. Then took out the trims out of the query so we can get back the values with spaces at the end of them.

Posted by gr...@apache.org.
Changed the test to verify that we filter out values that aren't exactly the same.
Then took out the trims out of the query so we can get back the values with spaces at the end of them.


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

Branch: refs/heads/USERGRID-903
Commit: 0a78e1544abde457f9256c978f7e0847b57834ac
Parents: c6f1dbe
Author: GERey <gr...@apigee.com>
Authored: Tue Aug 4 16:19:41 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Tue Aug 4 16:19:41 2015 -0700

----------------------------------------------------------------------
 .../persistence/index/impl/EsQueryVistor.java   |  2 +-
 .../index/query/tree/StringLiteral.java         |  2 +-
 .../rest/applications/queries/OrderByTest.java  | 24 ++++++++++++--------
 3 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a78e154/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index 7b66c0d..50d64fc 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -363,7 +363,7 @@ public class EsQueryVistor implements QueryVisitor {
 
         //special case so we support our '*' char with wildcard
         if ( value instanceof String ) {
-            final String stringValue = (( String ) value).toLowerCase().trim();
+            final String stringValue = (( String ) value).toLowerCase();
 
             // or field is just a string that does need a prefix us a query
             if ( stringValue.contains( "*" ) ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a78e154/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
index 92f9033..8b0bf52 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
@@ -53,7 +53,7 @@ public class StringLiteral extends Literal<String> {
     /** Parse the value and set the optional end value */
     private void parseValue( String value ) {
 
-        this.value = value.trim().toLowerCase();
+        this.value = value.toLowerCase();
 
         if ( "*".equals( value ) ) {
             this.value = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0a78e154/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index 2a16d96..869d5b1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -44,13 +44,13 @@ public class OrderByTest extends QueryTestBase {
         int numOfEntities = 20;
         String collectionName = "activities";
         //create our test entities
-        generateTestEntities(numOfEntities, collectionName);
+        generateTestEntities( numOfEntities, collectionName );
 
         QueryParameters params = new QueryParameters()
             .setQuery("select * order by ordinal asc")
             .setLimit(numOfEntities);
         Collection activities = this.app().collection("activities").get(params);
-        assertEquals(numOfEntities, activities.getResponse().getEntityCount());
+        assertEquals( numOfEntities, activities.getResponse().getEntityCount() );
         //results should be ordered by ordinal
         int index = 0;
         while (activities.hasNext()) {
@@ -63,19 +63,23 @@ public class OrderByTest extends QueryTestBase {
     @Test
     public void testValueWithSpaceAtEndStillQueryable() throws IOException {
         String collectionName = "stuff";
-        Entity lowerCaseEntity = new Entity();
-        lowerCaseEntity.put( "name","thing1" );
-        lowerCaseEntity.put( "random","fury " );
-
-        this.app().collection( collectionName ).post( lowerCaseEntity );
-
+        Entity spaceAtTheEndOfString = new Entity();
+        spaceAtTheEndOfString.put( "name","thing1" );
+        spaceAtTheEndOfString.put( "random", "fury " );
+        this.app().collection( collectionName ).post( spaceAtTheEndOfString );
+
+        //Add an extra entity to make sure this won't be returned in the below query.
+        Entity noSpaceButSimilarString = new Entity();
+        noSpaceButSimilarString.put( "name","thing2" );
+        noSpaceButSimilarString.put( "random", "fury" );
+        this.app().collection( collectionName ).post( noSpaceButSimilarString );
         refreshIndex();
 
         QueryParameters params = new QueryParameters()
-            .setQuery("select * where random = 'fury' ");
+            .setQuery("select * where random = 'fury ' ");
         Collection activities = this.app().collection(collectionName).get(params);
         assertEquals(1, activities.getResponse().getEntityCount());
-        assertEquals( "fury",activities.getResponse().getEntities().get( 0 ).get( "random" ) );
+        assertEquals( "fury ",activities.getResponse().getEntities().get( 0 ).get( "random" ) );
     }
 
     /**