Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make case insensitive ordering fall back on ordering by case #378

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ModelItemTreeItem extends TreeItem implements Comparable<TreeItem> {
ModelItemTreeItem other = that as ModelItemTreeItem
res = this.hasChildren() <=> other.hasChildren()
if (res == 0) res = this.order <=> other.order
if (res == 0) res = this.label?.toLowerCase() <=> other.label?.toLowerCase()
if (res == 0) res = this.label <=> other.label
res
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class TreeItem implements Comparable<TreeItem> {
int compareTo(TreeItem that) {
def res = this.domainTypeIndex <=> that.domainTypeIndex
if (res == 0) res = this.label?.toLowerCase() <=> that.label?.toLowerCase()
if (res == 0) res = this.label <=> that.label
res
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,14 @@ abstract class CatalogueItemService<K extends CatalogueItem> implements MdmDomai
private static StringBuilder addLowercaseSort(StringBuilder stringBuilder, String ciQueryPrefix, String sort, String order, boolean isDistinct, boolean isSingle) {
StringBuilder sortedQuery = new StringBuilder()
// Need to add the lower variant to the select query if isDistinct
if (isDistinct) sortedQuery.append('\n, lower(').append(ciQueryPrefix).append('.').append(sort).append(') ')
if (isDistinct) {
sortedQuery.append('\n, lower(').append(ciQueryPrefix).append('.').append(sort).append(') ')
sortedQuery.append(', ').append(ciQueryPrefix).append('.').append(sort)
}
sortedQuery.append(stringBuilder.toString())
if (isSingle) sortedQuery.append('\nORDER BY ')
sortedQuery.append('lower(').append(ciQueryPrefix).append('.').append(sort).append(') ').append(order)
sortedQuery.append(', ').append(ciQueryPrefix).append('.').append(sort).append(' ').append(order)
}

String applyHQLFilters(String originalQuery, String ciQueryPrefix, Map filters) {
Expand Down