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/08/27 23:32:25 UTC

[GitHub] betodealmeida commented on a change in pull request #5730: [sql_json] allow not specifying client_id

betodealmeida commented on a change in pull request #5730: [sql_json] allow not specifying client_id
URL: https://github.com/apache/incubator-superset/pull/5730#discussion_r213146660
 
 

 ##########
 File path: superset/views/core.py
 ##########
 @@ -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=int(g.user.get_id()) if g.user and g.user.get_id() else None,
 
 Review comment:
   I know that right now `admin` has user id 1, but in the future it could change to be 0 and it would break this code. I think it's better to be more explicit here an unravel the one liner:
   
   ```python
   client_id = request.form.get('client_id') or utils.shortid()
   
   try:
       user_id = int(g.user.get_id())
   except Exception:
       user_id = None
   
   query = Query(
       ...
       user_id=user_id,
       client_id=client_id,
   )
   ```

----------------------------------------------------------------
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