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/10 22:41:04 UTC

incubator-usergrid git commit: Fixed issue with having queries with spaces at the end being unqueryable.

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-903-two-dot-o [created] f65eac68c


Fixed issue with having queries with spaces at the end being unqueryable.


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

Branch: refs/heads/USERGRID-903-two-dot-o
Commit: f65eac68c57489368ad20487210dd76ef18ac11d
Parents: 4887b02
Author: GERey <gr...@apigee.com>
Authored: Mon Aug 10 13:41:01 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Mon Aug 10 13:41:01 2015 -0700

----------------------------------------------------------------------
 .../index/query/tree/StringLiteral.java         |  2 +-
 .../rest/applications/queries/OrderByTest.java  | 25 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f65eac68/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/f65eac68/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 75f4a3f..1005412 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
@@ -124,6 +124,31 @@ public class OrderByTest extends QueryTestBase {
         }
     }
 
+
+    @Test
+    public void testValueWithSpaceAtEndStillQueryable() throws Exception {
+        String collectionName = "stuff";
+
+        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();
+
+        Thread.sleep( 1000 );
+        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 Boolean properties
      *