Эх сурвалжийг харах

HUE-8758 [editor] Add notion of dialects to sample tables

Romain 5 жил өмнө
parent
commit
b7b9be6307

+ 1 - 0
apps/beeswax/data/tables_standard.json

@@ -4,6 +4,7 @@
     "create_sql": "CREATE TABLE `employe_sample` (\n  `code` text ,\n  `description` text ,\n  `total_emp` int ,\n  `salary` int )\n",
     "insert_sql": "INSERT INTO employe_sample (`code`, `description`, `total_emp`, `salary`)\nVALUES %(values)s",
     "table_name": "employe_sample",
+    "dialects": ["mysql"],
     "transactional": true
   }
 ]

+ 8 - 7
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -97,13 +97,14 @@ class Command(BaseCommand):
     table_file.close()
 
     for table_dict in table_list:
-      try:
-        table = SampleTable(table_dict, dialect, db_name, interpreter=interpreter, request=request)
-        table.install(django_user)
-      except Exception as ex:
-        msg = str(ex)
-        LOG.error(msg)
-        raise InstallException(_('Could not install table %s: %s') % (table_dict['table_name'], msg))
+      if dialect in table_dict.get('dialects', [dialect]):
+        try:
+          table = SampleTable(table_dict, dialect, db_name, interpreter=interpreter, request=request)
+          table.install(django_user)
+        except Exception as ex:
+          msg = str(ex)
+          LOG.error(msg)
+          raise InstallException(_('Could not install table %s: %s') % (table_dict['table_name'], msg))
 
   def _install_queries(self, django_user, dialect, interpreter=None):
     design_file = open(os.path.join(LOCAL_EXAMPLES_DATA_DIR.get(), 'queries.json'))