prathamesh04 opened a new pull request, #42197:
URL: https://github.com/apache/superset/pull/42197

   ### SUMMARY
   
   Fixes #41245
   
   The `SET_DATABASES` reducer was **replacing** the entire `databases` state 
object with only the newly fetched results. When SQL Lab initializes, it 
fetches databases via the API (default `page_size=20` from FAB), and the 
reducer would overwrite the full databases map with just those 20 results. This 
caused the "database not found" warning for any saved tab referencing a 
database outside the first page of results.
   
   The fix changes the reducer to **merge** new databases into the existing 
state, preserving any previously loaded database entries. This is a one-line 
change:
   
   ```diff
   - return { ...state, databases };
   + return { ...state, databases: { ...state.databases, ...databases } };
   ```
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A (state management fix, no visual change)
   
   ### TESTING INSTRUCTIONS
   
   1. Create a Superset instance with >20 databases
   2. Save a SQL Lab tab with a database whose ID is not in the first 20 results
   3. Reload SQL Lab — the "database not found" warning should no longer appear
   4. Run the new unit tests: `npx jest src/SqlLab/reducers/sqlLab.test.ts`
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: #41245
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


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