Enhance COLLATE on ORDER BY to be case insensitive
and to throw exception if the declared collate does not exist
@@ -3,10 +3,12 @@ package com.orientechnologies.orient.core.sql.parser;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.collate.OCollate;
import com.orientechnologies.orient.core.command.OCommandContext;
+import com.orientechnologies.orient.core.exception.OCommandExecutionException;
import com.orientechnologies.orient.core.sql.OSQLEngine;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
+import java.util.Locale;
import java.util.Map;
/**
@@ -107,6 +109,15 @@ public class OOrderByItem {
}
if (collateVal != null) {
collateStrategy = OSQLEngine.getCollate(String.valueOf(collateVal));
+ if (collateStrategy == null) {
+ collateStrategy = OSQLEngine.getCollate(String.valueOf(collateVal).toUpperCase(Locale.ENGLISH));
+ }
+ if (collateStrategy == null) {
+ collateStrategy = OSQLEngine.getCollate(String.valueOf(collateVal).toLowerCase(Locale.ENGLISH));
+ }
+ if (collateStrategy == null) {
+ throw new OCommandExecutionException("Invalid collate for ORDER BY: " + collateVal);
+ }
}
}
