bito-code-review[bot] commented on PR #44933:
URL: https://github.com/apache/superset/pull/44933#issuecomment-5966131987

   <!-- Bito Reply -->
   The flagged issue is correct. The `postForm` method sends data as top-level 
form fields, but the `/sqllab/` endpoint expects the query data to be nested 
within a `form_data` field. To resolve this, the payload passed to `postForm` 
should be wrapped in a `form_data` object, serialized as a JSON string.
   
   Here is the corrected implementation for the `openSQL` function (assuming it 
is defined within `ViewQueryModalFooter.tsx`):
   
   ```typescript
   const openSQL = (newWindow: boolean) => {
     const payload = {
       datasourceKey: datasource.id + '__' + datasource.type,
       sql: datasource.sql,
     };
     if (newWindow) {
       SupersetClient.postForm('/sqllab/', { form_data: JSON.stringify(payload) 
});
     } else {
       history.push({
         pathname: '/sqllab',
         state: { requestedQuery: payload },
       });
     }
   };
   ```
   
   I have validated this fix against the provided diff. Would you like me to 
check the other comments on this PR to see if there are more issues to address?
   
   
**superset-frontend/src/explore/components/controls/ViewQueryModalFooter.tsx**
   ```
   const openSQL = (newWindow: boolean) => {
     const payload = {
       datasourceKey: datasource.id + '__' + datasource.type,
       sql: datasource.sql,
     };
     if (newWindow) {
       SupersetClient.postForm('/sqllab/', { form_data: JSON.stringify(payload) 
});
     } else {
       history.push({
         pathname: '/sqllab',
         state: { requestedQuery: payload },
       });
     }
   };
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to