瀏覽代碼

HUE-7091 [assist] Follow case when adding filters with the risk quick-fix

Johan Ahlen 8 年之前
父節點
當前提交
5337a95
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      desktop/core/src/desktop/templates/assist.mako

+ 8 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -2162,6 +2162,12 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
         var self = this;
         if (self.activeLocations() && self.activeEditor()) {
           self.activeLocations().activeStatementLocations.every(function (location) {
+            var isLowerCase = false;
+            if (self.activeLocations().activeStatementLocations && self.activeLocations().activeStatementLocations.length > 0) {
+              var firstToken = self.activeLocations().activeStatementLocations[0].firstToken;
+              isLowerCase = firstToken === firstToken.toLowerCase();
+            }
+
             if (location.type === 'whereClause' && !location.subquery && (location.missing || riskId === 22 )) {
               self.activeEditor().moveCursorToPosition({
                 row: location.location.last_line - 1,
@@ -2173,7 +2179,8 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
                 self.activeEditor().session.insert(self.activeEditor().getCursorPosition(), ' ');
               }
 
-              self.activeEditor().session.insert(self.activeEditor().getCursorPosition(), location.missing ? 'where ' : 'and ');
+              var operation = location.missing ? 'WHERE ' : 'AND ';
+              self.activeEditor().session.insert(self.activeEditor().getCursorPosition(), isLowerCase ? operation.toLowerCase() : operation);
               self.activeEditor().focus();
 
               if (riskId === 22) {