rusackas commented on code in PR #38490:
URL: https://github.com/apache/superset/pull/38490#discussion_r3526558039


##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -415,6 +416,15 @@ export function dbReducer(
           [action.payload.name]: action.payload.checked,
         };
       }
+      if (action.payload.name === 'cache_timeout') {
+        const val = Number(action.payload.value);

Review Comment:
   Here's an apply-able version, `Number('')` is `0` not `NaN`, so treating an 
empty field as `NaN` lets it fall through to `undefined` and clear back to the 
default.\n\n```suggestion\n        const val =\n          action.payload.value 
=== '' ? NaN : Number(action.payload.value);\n```



##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -343,13 +343,14 @@ export function dbReducer(
         action.payload.name === 'schema_cache_timeout' ||
         action.payload.name === 'table_cache_timeout'
       ) {
+        const timeoutValue = Math.max(0, Number(action.payload.value) || 0);

Review Comment:
   Same idea here, an empty field should drop the key rather than store `0`. 
Setting it `undefined` lets `JSON.stringify` omit it so it goes back to unset.
   
   ```suggestion
           const timeoutValue =
             action.payload.value === ''\n            ? undefined\n            
: Math.max(0, Number(action.payload.value) || 0);\n```



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