You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/09/06 05:34:26 UTC

[GitHub] mistercrunch closed pull request #5730: [sql_json] allow not specifying client_id

mistercrunch closed pull request #5730: [sql_json] allow not specifying client_id
URL: https://github.com/apache/incubator-superset/pull/5730
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/utils.py b/superset/utils.py
index b1583084eb..6bfbb34cfe 100644
--- a/superset/utils.py
+++ b/superset/utils.py
@@ -1016,3 +1016,7 @@ def get_username():
 
 def MediumText():
     return Text().with_variant(MEDIUMTEXT(), 'mysql')
+
+
+def shortid():
+    return '{}'.format(uuid.uuid4())[-12:]
diff --git a/superset/views/core.py b/superset/views/core.py
index 2e4a8e8bc5..345c386c86 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -2395,6 +2395,8 @@ def sql_json(self):
                 tmp_table_name,
             )
 
+        client_id = request.form.get('client_id') or utils.shortid()
+
         query = Query(
             database_id=int(database_id),
             limit=mydb.db_engine_spec.get_limit_from_sql(sql),
@@ -2406,8 +2408,8 @@ def sql_json(self):
             status=QueryStatus.PENDING if async_ else QueryStatus.RUNNING,
             sql_editor_id=request.form.get('sql_editor_id'),
             tmp_table_name=tmp_table_name,
-            user_id=int(g.user.get_id()),
-            client_id=request.form.get('client_id'),
+            user_id=g.user.get_id() if g.user else None,
+            client_id=client_id,
         )
         session.add(query)
         session.flush()


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org