Hello Eli Mesika,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/18394
to review the following change.
Change subject: core: Search query sortby return some wrongly...
......................................................................
core: Search query sortby return some wrongly...
Search query sortby return some wrongly sorted results
Adding explicitly "NULLS LAST" when DESC ORDER BY is used
This is the ORDER BY Syntax :
ORDER BY sort_expression1 [ASC | DESC] [NULLS { FIRST | LAST }]
[, sort_expression2 [ASC | DESC] [NULLS { FIRST | LAST }] ...]
The NULLS FIRST and NULLS LAST options can be used to determine whether
nulls appear before or after non-null values in the sort ordering. By
default, null values sort as if larger than any non-null value; that is,
NULLS FIRST is the default for DESC order, and NULLS LAST otherwise.
Change-Id: Ib1f25076ffe7c0c6e1dbd609f7b175c8c9e34ac5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=962560
Signed-off-by: Eli Mesika <[email protected]>
---
M
backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
1 file changed, 3 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/94/18394/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 7d75579..141dcd1 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
@@ -841,7 +841,9 @@
StringFormat.format(" ORDER BY %1$s",
conditionFieldAC.getSortableDbField(obj.getBody()));
break;
case SORT_DIRECTION:
- sortByPhrase = StringFormat.format("%1$s %2$s",
sortByPhrase, obj.getBody());
+ // Forcing any sorting using DESC to show NULL values last
(NULLS FIRST is the default)
+ String direction =
(obj.getBody().equalsIgnoreCase("desc")) ? "DESC NULLS LAST" : obj.getBody();
+ sortByPhrase = StringFormat.format("%1$s %2$s",
sortByPhrase, direction);
break;
default:
break;
--
To view, visit http://gerrit.ovirt.org/18394
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1f25076ffe7c0c6e1dbd609f7b175c8c9e34ac5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches