Преглед изворни кода

HUE-4701 [editor] Older saved queries throw "'NoneType' object has no attribute 'update_data'"

Updating the UUID in the json data of queries in case it mismatches with the Document UUID.
Romain Rigaux пре 9 година
родитељ
комит
b059cec
2 измењених фајлова са 12 додато и 2 уклоњено
  1. 1 1
      desktop/core/src/desktop/api2.py
  2. 11 1
      desktop/core/src/desktop/tests_doc2.py

+ 1 - 1
desktop/core/src/desktop/api2.py

@@ -168,7 +168,7 @@ def get_document(request):
       notebook = Notebook(document=document)
       notebook = upgrade_session_properties(request, notebook)
       data = json.loads(notebook.data)
-      if 'uuid' not in data:
+      if data.get('uuid') != document.uuid: # Old format < 3.11
         data['uuid'] = document.uuid
 
     response['data'] = data

+ 11 - 1
desktop/core/src/desktop/tests_doc2.py

@@ -18,7 +18,7 @@
 
 import json
 
-from nose.tools import assert_equal, assert_false, assert_true
+from nose.tools import assert_equal, assert_false, assert_true, assert_not_equal
 from django.contrib.auth.models import User
 
 from desktop.lib.django_test_util import make_logged_in_client
@@ -99,6 +99,16 @@ class TestDocument2(object):
     assert_equal(-1, data['status'])
     assert_true('not found' in data['message'])
 
+    # Document UUID and XML UUID missmatch
+    response = self.client.get('/desktop/api2/doc/', {'uuid': doc.uuid})
+    data = json.loads(response.content)
+    doc.uuid = '1234-5678-9'
+    doc.save()
+    assert_not_equal(doc.uuid, data['document']['uuid'])
+    response = self.client.get('/desktop/api2/doc/', {'uuid': doc.uuid})
+    data = json.loads(response.content)
+    assert_equal(doc.uuid, data['document']['uuid'])
+
 
   def test_directory_create_and_rename(self):
     response = self.client.post('/desktop/api2/doc/mkdir', {'parent_uuid': json.dumps(self.home_dir.uuid), 'name': json.dumps('test_mkdir')})