Skip to content

fix(sqllab): preserve database state on SET_DATABASES#41281

Open
GagandeepSingh20 wants to merge 1 commit into
apache:masterfrom
GagandeepSingh20:fix-sql-lab-database-state
Open

fix(sqllab): preserve database state on SET_DATABASES#41281
GagandeepSingh20 wants to merge 1 commit into
apache:masterfrom
GagandeepSingh20:fix-sql-lab-database-state

Conversation

@GagandeepSingh20

@GagandeepSingh20 GagandeepSingh20 commented Jun 22, 2026

Copy link
Copy Markdown

SUMMARY

Fixes an issue where SQL Lab could lose previously loaded database entries when additional database pages were fetched.

The SET_DATABASES reducer currently replaces the entire databases map in Redux state with the latest API response. Since DatabaseSelector loads databases through paginated requests, loading another page can remove database entries that were already present in state.

This change updates the reducer to merge incoming database entries into the existing state instead of replacing the entire map. A regression test has also been added to verify that previously loaded databases are preserved when additional database results are received.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable (no UI changes).

TESTING INSTRUCTIONS

Run:
npm run test -- src/SqlLab/reducers/sqlLab.test.ts
Verify the reducer test suite passes.
Verify the new regression test confirms that existing database entries remain available after dispatching SET_DATABASES with additional database results.

ADDITIONAL INFORMATION

@dosubot dosubot Bot added the sqllab Namespace | Anything related to the SQL Lab label Jun 22, 2026
@bito-code-review

bito-code-review Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #531c26

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 07e403d..07e403d
    • superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
    • superset-frontend/src/SqlLab/reducers/sqlLab.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 07e403d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a38fb06797b8d0008605136
😎 Deploy Preview https://deploy-preview-41281--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines +50 to +55
const action = actions.setDatabases([
{
...incomingDb,
extra: '{}',
},
] as any);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: Remove the any cast on the setDatabases payload and type it using the action creator's expected argument type (or a specific database DTO type) so the test validates real compile-time contracts. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

This is TypeScript code in a modified test file, and it uses as any on the setDatabases payload. The custom rule explicitly forbids new or modified TypeScript/TSX code from using any, so this is a real violation.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
**Line:** 50:55
**Comment:**
	*Custom Rule: Remove the `any` cast on the `setDatabases` payload and type it using the action creator's expected argument type (or a specific database DTO type) so the test validates real compile-time contracts.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

},
] as any);

const newState = sqlLabReducer(state as any, action);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: Avoid casting state to any; declare state with the proper reducer state type so the reducer call remains fully type-checked. [custom_rule]

Severity Level: Minor ⚠️

Why it matters? 🤔

This modified TypeScript test line casts state to any, which directly violates the rule against using any in new or changed TS/TSX code. The suggestion is therefore valid.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/SqlLab/reducers/sqlLab.test.ts
**Line:** 57:57
**Comment:**
	*Custom Rule: Avoid casting `state` to `any`; declare `state` with the proper reducer state type so the reducer call remains fully type-checked.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@rusackas rusackas requested a review from sadpandajoe June 22, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M sqllab Namespace | Anything related to the SQL Lab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant