Skip to content

fix(client-core): Fix for the issue with Generated SQL tab in playground #9675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

UsmanYasin
Copy link
Contributor

@UsmanYasin UsmanYasin commented Jun 12, 2025

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Issue Reference this PR resolves

This PR fixes issue 9589

Description of Changes Made (if issue reference is not provided)

The generated SQL tab started crashing since v1.3.16 and it was linked to the PR 9562. There are multiple ways of fixing the issue so I have attempted the one with minimal changes. Since I have limited understanding of the codebase, happy to modify the PR if a different approach should be taken to fix the problem.

@UsmanYasin UsmanYasin requested a review from a team as a code owner June 12, 2025 15:42
@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label Jun 12, 2025
@KSDaemon
Copy link
Member

@UsmanYasin Hey! Good catch! Thnx for fixing it!

@@ -627,7 +627,7 @@ class CubeApi {
query,
signal: options?.signal
}),
(response: any) => (Array.isArray(response) ? response.map((body) => new SqlQuery(body)) : new SqlQuery(response)),
Copy link
Member

@KSDaemon KSDaemon Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I think it would be better to fix the original place that was changed. Because this changes the semantics.

    return this.sqlQuery.sql;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted this change and implemented the fix in SqlQuery.ts file. Introduced this type SqlQueryWrapper = { sql: SqlData }; and changed the constructor argument and private sqlQuery variable type to SqlQueryWrapper instead of SqlData.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thnx!
Btw, have you tested it locally?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested by generating the dev Docker image, and the SQL Generated Tab appears to be working afterwards. I’m not entirely sure how to run all the tests locally or if there are any tests covering this class. I’ll check the tests and add some if they don’t already exist.
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be just awesome! I think we can add unit tests for this class for the future!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests added for SqlQuery.ts

@KSDaemon KSDaemon changed the title fix(client-core): Suggested fix for the issue with Generated SQL tab in playground fix(client-core): Fix for the issue with Generated SQL tab in playground Jun 13, 2025
@KSDaemon KSDaemon self-assigned this Jun 13, 2025
@pnedelko
Copy link

Hope it gets merged and fixed soon!

@KSDaemon
Copy link
Member

Thnx for adding tests!
Let's merge!

@KSDaemon KSDaemon merged commit 17570d4 into cube-js:master Jun 16, 2025
28 of 29 checks passed
marianore-muttdata pushed a commit to MuttData/cube that referenced this pull request Jun 17, 2025
…und (cube-js#9675)

* fix: Suggested fix for the issue with Generated SQL tab in playground

* fix: Revised fixed to keep the same semantics

* fix: correct SqlQuery types and add unit tests

---------

Co-authored-by: Usman Yasin <usman.yasin@rystadenergy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:community Contribution from Cube.js community members.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants