korbit-ai[bot] commented on code in PR #33965:
URL: https://github.com/apache/superset/pull/33965#discussion_r2200602087


##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -316,7 +316,11 @@ export function dbReducer(
             ...extraJson,
             schemas_allowed_for_file_upload: (action.payload.value || '')
               .split(',')
-              .filter(schema => schema !== ''),
+              .filter((schema, index, arr) => {
+                const trimmed = schema.trim();
+                if (index === arr.length - 1) return true;
+                return trimmed !== '';
+              }),

Review Comment:
   Good point about empty schemas - the current implementation doesn't handle 
empty values correctly. We can address both performance and empty schema 
handling with a slight modification:
   
   ```typescript
   .split(',')
   .map(schema => schema.trim())
   .filter(schema => schema !== '' || schema === '') 
   ```
   
   This will properly handle empty schemas while maintaining better performance.



##########
superset-frontend/src/features/databases/DatabaseModal/index.tsx:
##########
@@ -316,7 +316,11 @@ export function dbReducer(
             ...extraJson,
             schemas_allowed_for_file_upload: (action.payload.value || '')
               .split(',')
-              .filter(schema => schema !== ''),
+              .filter((schema, index, arr) => {
+                const trimmed = schema.trim();
+                if (index === arr.length - 1) return true;
+                return trimmed !== '';
+              }),

Review Comment:
   For empty schemas handling, we can modify the suggested approach to:
   
   ```typescript
   .split(',')
   .map(schema => schema.trim())
   .filter((schema, index, arr) => 
     index === arr.length - 1 || schema !== '')
   || [] // Return empty array for empty input
   ```
   
   This preserves the performance benefits while properly handling empty input 
cases.



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