Eli Mesika has uploaded a new change for review.

Change subject: core:Hosts from another data center ...(#874660)
......................................................................

core:Hosts from another data center ...(#874660)

Hosts from another data center displayed when clicked on Hosts in tree view for 
cluster names with a single difference.

Search Engine is using currently the ILIKE keyword to enable
case-insensitive searches. Postgres treats the character '_' in a value
when using LIKE/ILIKE teh same way as '?' is used for regular
expressions. (i.e. match any single value)
This patch looks for the character '_' in values passed to the search
engine and proceed then with a backslash such that they will be treated
as a regular character and Search Engine will return the correct result.

Change-Id: I2a5e9946f7795827d1abd50f05e641d90802e1e8
Signed-off-by: Eli Mesika <emes...@redhat.com>
---
M 
backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/9207/1

diff --git 
a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
 
b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
index f0fac17..77ea2d5 100644
--- 
a/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
+++ 
b/backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
@@ -1061,6 +1061,9 @@
             String objName,
             ConditionType conditionType) {
         final String tableName = mSearchObjectAC.getRelatedTableName(objName);
+        // Since '_' is treated in Postgres as '?' when using like, (i.e. 
match any single character)
+        // we have to escape this character in the value to make it treated as 
a regular character.
+        customizedValue = customizedValue.replace("_", "\\_");
         switch (conditionType) {
         case FreeText:
         case FreeTextSpecificObj:


--
To view, visit http://gerrit.ovirt.org/9207
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a5e9946f7795827d1abd50f05e641d90802e1e8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <emes...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to