I3eka commented on code in PR #43278:
URL: https://github.com/apache/superset/pull/43278#discussion_r3807951782


##########
superset-frontend/src/SqlLab/actions/sqlLab.ts:
##########
@@ -686,7 +686,17 @@ export function syncQueryEditor(
   queryEditor: QueryEditor,
 ): SqlLabThunkAction<Promise<unknown>> {
   return function (dispatch: AppDispatch, getState: GetState) {
-    const { tables, queries } = getState().sqlLab;
+    const { tables, queries, databases } = getState().sqlLab;
+    const databaseWasRemoved =
+      queryEditor.dbId !== undefined && !databases[queryEditor.dbId];
+    const queryEditorToMigrate = databaseWasRemoved

Review Comment:
   Good catch. `SET_DATABASES` merges paginated selector results, so the Redux 
map is not authoritative. Fixed in da89b472ae by checking the selected ID 
against the accessible `/api/v1/database/` list immediately before the one-time 
migration; a zero-count result clears `dbId`, catalog, and schema. The 
regression case deliberately keeps ID 99 in Redux while the API reports it 
missing.



##########
superset-frontend/src/SqlLab/actions/sqlLab.ts:
##########
@@ -696,11 +706,16 @@ export function syncQueryEditor(
     );
     return SupersetClient.post({
       endpoint: '/tabstateview/',
-      postPayload: { queryEditor },
+      postPayload: {
+        queryEditor: {
+          ...queryEditorToMigrate,
+          dbId: queryEditorToMigrate.dbId ?? null,
+        },
+      },

Review Comment:
   Agreed. da89b472ae now discards the associated local table-schema entries 
when that authoritative check reports the database missing, and skips 
`/tableschemaview/` migration for them. The regression test asserts both the 
`REMOVE_TABLES` action and zero table-schema POSTs, so the deleted foreign key 
is no longer retried.



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