Eli Mesika has uploaded a new change for review. Change subject: core: Underscores in tag names break tags ......................................................................
core: Underscores in tag names break tags 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. Due to changes between PG8.x and PG9.x on ESCAPE representation in a string, we should figure out what PG Release is running in order to escape the special character(_) correctly The bug was that the above treatment was done on the value no matter what the operator is, while this change should be applied only for the LIKE or ILIKE operator. If the operator is '=' '!=' 'IN' etc. the '_' should stay as is in the passed value and not been manipulated. Change-Id: Ia4c289e198b59afc4acf3e671ea65f2cdf8e31ad Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=949484 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, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/94/15594/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 6dc1536..e241f82 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 @@ -42,7 +42,7 @@ mPluralAC = new BaseAutoCompleter("S"); mSortbyAC = new BaseAutoCompleter("SORTBY"); mPageAC = new BaseAutoCompleter("PAGE"); - mSortDirectionAC = new BaseAutoCompleter( "ASC", "DESC" ); + mSortDirectionAC = new BaseAutoCompleter("ASC", "DESC"); mAndAC = new BaseAutoCompleter("AND"); mOrAC = new BaseAutoCompleter("OR"); mDotAC = new BaseAutoCompleter("."); @@ -1099,22 +1099,23 @@ 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. - // Due to changes between PG8.x and PG9.x on ESCAPE representation in a string, we should - // figure out what PG Release is running in order to escape the special character(_) correctly - // This is done in a IF block and not with Method Factory pattern since this is the only change - // right now, if we encounter other changes, this will be refactored to use the Method Factory pattern. - String replaceWith = "_"; - int pgMajorRelease = Config.<Integer> GetValue(ConfigValues.PgMajorRelease); - if (pgMajorRelease == PgMajorRelease.PG8.getValue()) { - replaceWith = "\\\\_"; + if (customizedRelation.equalsIgnoreCase("LIKE") || customizedRelation.equalsIgnoreCase("ILIKE")) { + // 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. + // Due to changes between PG8.x and PG9.x on ESCAPE representation in a string, we should + // figure out what PG Release is running in order to escape the special character(_) correctly + // This is done in a IF block and not with Method Factory pattern since this is the only change + // right now, if we encounter other changes, this will be refactored to use the Method Factory pattern. + String replaceWith = "_"; + int pgMajorRelease = Config.<Integer> GetValue(ConfigValues.PgMajorRelease); + if (pgMajorRelease == PgMajorRelease.PG8.getValue()) { + replaceWith = "\\\\_"; + } + else if (pgMajorRelease == PgMajorRelease.PG9.getValue()) { + replaceWith = "\\_"; + } + customizedValue = customizedValue.replace("_", replaceWith); } - else if (pgMajorRelease == PgMajorRelease.PG9.getValue()) { - replaceWith = "\\_"; - } - - customizedValue = customizedValue.replace("_", replaceWith); switch (conditionType) { case FreeText: case FreeTextSpecificObj: -- To view, visit http://gerrit.ovirt.org/15594 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4c289e198b59afc4acf3e671ea65f2cdf8e31ad 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