-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix: group empty string as null #10060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces changes to two key files: Changes
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Uffizzi Preview |
635d14d to
a476e8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/nocodb/src/db/BaseModelSqlv2.ts (3)
4486-4489: Standardize empty string handling for SingleSelect columnsAdded consistent handling of empty strings by converting them to NULL using COALESCE and NULLIF. This ensures uniform behavior across the application.
This change aligns with the best practice of treating empty strings as NULL values in database operations, which helps maintain data consistency and simplifies querying.
8072-8074: Improve group value handling for empty stringsEnhanced the grouping logic to:
- Handle both NULL and empty string values consistently
- Explicitly convert empty strings to NULL after trimming
Consider extracting the empty string check into a reusable utility function since this pattern may be needed elsewhere:
function isEmptyString(val: any): boolean { return typeof val === 'string' && val.trim() === ''; }Also applies to: 8096-8101
8137-8137: Enhance GROUP BY handling for empty stringsModified the GROUP BY query to use COALESCE and NULLIF for consistent empty string handling across different SQL dialects. Also added proper column configuration to support this change.
This change improves cross-database compatibility by using standard SQL functions. The column configuration addition makes the code more maintainable.
Also applies to: 8192-8196
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/nc-gui/composables/useKanbanViewStore.ts(2 hunks)packages/nocodb/src/db/BaseModelSqlv2.ts(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/nc-gui/composables/useKanbanViewStore.ts
a476e8e to
7837570
Compare
7837570 to
932ddce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/nocodb/src/db/BaseModelSqlv2.ts (1)
Line range hint
4486-8205: Consider adding unit tests for empty string handlingWhile the implementation looks good, it would be beneficial to add comprehensive unit tests to verify the behavior of empty string handling across different scenarios:
- SingleSelect field with empty string
- SingleSelect field with NULL
- Grouping by SingleSelect field with mixed empty strings and NULLs
Would you like me to help create unit tests for these scenarios?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/nc-gui/composables/useKanbanViewStore.ts(2 hunks)packages/nocodb/src/db/BaseModelSqlv2.ts(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/nc-gui/composables/useKanbanViewStore.ts
🔇 Additional comments (4)
packages/nocodb/src/db/BaseModelSqlv2.ts (4)
4486-4489: LGTM: Proper handling of empty strings for SingleSelect fields
The implementation correctly converts empty strings to NULL using COALESCE and NULLIF for SingleSelect fields. This ensures consistent behavior across the application.
8072-8078: LGTM: Consistent handling of NULL and empty strings in grouping
The WHERE clause properly handles both NULL values and empty strings for SingleSelect fields. The implementation uses proper query builder methods and maintains consistency with the rest of the codebase.
8141-8146: LGTM: Proper GROUP BY handling for SingleSelect fields
The implementation correctly uses COALESCE and NULLIF in the GROUP BY clause to ensure consistent grouping behavior for SingleSelect fields with empty strings.
8201-8205: LGTM: Consistent column selection for grouped queries
The column selection is properly updated to match the new grouping behavior, maintaining consistency with the empty string handling changes.
Change Summary
#10057
Change type