Procházet zdrojové kódy

HUE-3885 [metastore] Add check to prevent space in table name in both create table wizards

Enrico Berti před 9 roky
rodič
revize
28df8cc

+ 2 - 0
apps/beeswax/src/beeswax/forms.py

@@ -284,6 +284,8 @@ class CreateTableForm(DependencyAwareForm):
 
 
 def _clean_tablename(db, name, database='default'):
+  if ' ' in name:
+    raise forms.ValidationError(_('Spaces are not allowed in table names.'))
   try:
     table = db.get_table(database, name)
     if table.name:

+ 5 - 1
apps/beeswax/src/beeswax/templates/create_table_manually.mako

@@ -797,7 +797,7 @@ ${ assist.assistPanel() }
       function validateForm() {
         // step 1
         var tableNameFld = $("input[name='table-name']");
-        if (!isValid($.trim(tableNameFld.val()))) {
+        if (!isValid($.trim(tableNameFld.val())) || !withoutSpaces($.trim(tableNameFld.val()))) {
           showFieldError(tableNameFld);
           return false;
         }
@@ -882,6 +882,10 @@ ${ assist.assistPanel() }
         return (str != "");
       }
 
+      function withoutSpaces(str) {
+        return (str.indexOf(" ") == -1);
+      }
+
       function showFieldError(field) {
         field.nextAll(".error-inline").not(".error-inline-bis").removeClass("hide");
       }

+ 6 - 1
apps/beeswax/src/beeswax/templates/execute.mako

@@ -793,6 +793,10 @@ ${ layout.menubar(section='query') }
 
 ${ commonshare() | n,unicode }
 
+<script>
+  var SqlAutocompleter2 = {};
+</script>
+
 <script src="${ static('desktop/js/hue.json.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/jquery.huedatatable.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.draggable-droppable-sortable.min.js') }" type="text/javascript" charset="utf-8"></script>
@@ -1219,7 +1223,8 @@ var autocompleter = new Autocompleter({
   snippet: snippet,
   user: HIVE_AUTOCOMPLETE_USER,
   oldEditor: true,
-  optEnabled: false
+  optEnabled: false,
+  useNewAutocompleter: false
 });
 
 var totalStorageUserPrefix = apiHelper.getTotalStorageUserPrefix(snippetType);