Просмотр исходного кода

[api] Refactor _patch_operation_id_request in public APIs

Harshg999 4 лет назад
Родитель
Сommit
4fb34a60e7
1 измененных файлов с 9 добавлено и 7 удалено
  1. 9 7
      desktop/core/src/desktop/api_public.py

+ 9 - 7
desktop/core/src/desktop/api_public.py

@@ -167,14 +167,16 @@ def _get_interpreter_from_dialect(dialect, user):
 
 
 def _patch_operation_id_request(django_request):
-  if django_request.POST.get('operationId') and not django_request.POST.get('snippet'):
-    data = {
-      'snippet': '{"type":"1","result":{}}',
-      'operationId': django_request.POST.get('operationId')
-    }
+  data = {}
 
-    django_request.POST = QueryDict(mutable=True)
-    django_request.POST.update(data)
+  if not django_request.POST.get('snippet'):
+    data['snippet'] = '{"type":"mysql","result":{}}'
+
+  if django_request.POST.get('operationId'):
+    data['operationId'] = django_request.POST.get('operationId')
+
+  django_request.POST = QueryDict(mutable=True)
+  django_request.POST.update(data)
 
 
 def get_django_request(request):