-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: enable is and isnot operator on JSON #11271
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
📝 WalkthroughWalkthroughThe changes introduce new helper functions to encapsulate repeated logic for checking if JSON fields are null, empty objects, or empty arrays in three handler files. These helpers are used to refactor existing code for the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Handler (General/MySQL/PG)
participant QueryBuilder
Client->>Handler (filter): Request filter with operator (e.g., is, isnot, blank, notblank)
alt Operator is "blank" or "notblank"
Handler->>Handler: Call appendIsNull or appendIsNotNull
Handler->>QueryBuilder: Add null/empty or not-null/not-empty condition
else Operator is "is" or "isnot"
Handler->>Handler: Switch on filter value (blank, empty, notblank, notempty)
Handler->>Handler: Call appendIsNull or appendIsNotNull as appropriate
Handler->>QueryBuilder: Add corresponding condition
else Other operators
Handler->>QueryBuilder: Apply existing logic
end
QueryBuilder-->>Handler: Query conditions updated
Handler-->>Client: Filtered results
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
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/field-handler/handlers/json/json.mysql.handler.ts (1)
110-138
: Well-implementedis
andisnot
operators!The implementation is consistent with the other handlers and properly handles the semantic string values.
One minor point to consider for all handlers: if invalid values are passed to these operators, they will silently do nothing. Consider either:
- Adding a default case to handle invalid values explicitly, or
- Adding validation in the
verifyFilter
method to ensure only supported values are usedThis would improve error handling, but the current implementation is functional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/nocodb/src/db/field-handler/handlers/json/json.general.handler.ts
(2 hunks)packages/nocodb/src/db/field-handler/handlers/json/json.mysql.handler.ts
(2 hunks)packages/nocodb/src/db/field-handler/handlers/json/json.pg.handler.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: release-docker / buildx
- GitHub Check: unit-tests-pg
- GitHub Check: unit-tests
🔇 Additional comments (7)
packages/nocodb/src/db/field-handler/handlers/json/json.pg.handler.ts (2)
9-42
: Well-structured helper functions for common operations!Extracting these helper functions is a great improvement as it encapsulates the repeated logic for checking null/empty JSON fields. This promotes code reusability and readability while reducing duplication.
120-149
: Good implementation ofis
andisnot
operators!The implementation handles semantic string values like 'blank', 'empty', 'notblank', and 'notempty' appropriately. The logic is consistent and properly reuses the helper functions.
Some suggestions for future enhancements:
- Consider adding documentation for these operators to help users understand the supported values
- It might be useful to handle invalid values with a default case in the nested switch statements
packages/nocodb/src/db/field-handler/handlers/json/json.general.handler.ts (3)
23-35
: Good extraction of helper functions!Nice job encapsulating repeated logic into helper functions. This improves code maintainability and readability.
Unlike the PostgreSQL handler where helpers are at module level, these are scoped to the filter method which is appropriate since they're only used there.
97-103
: Good refactoring ofblank
operator!Using the helper function makes the code more concise and readable.
105-133
: Well-implementedis
andisnot
operators!The implementation is consistent with the PostgreSQL handler and properly handles all semantic string values.
packages/nocodb/src/db/field-handler/handlers/json/json.mysql.handler.ts (2)
23-35
: Good extraction of MySQL-specific helper functions!These helper functions properly handle MySQL JSON syntax with
JSON_UNQUOTE
. The implementation correctly encapsulates the repeated logic for checking null and empty JSON fields.
102-108
: Good refactoring ofblank
andnotblank
operators!Using the helper functions makes the code more concise and readable.
Uffizzi Ephemeral Environment Deploying☁️ https://app.uffizzi.com/github.com/nocodb/nocodb/pull/11271 ⚙️ Updating now by workflow run 14797101331. What is Uffizzi? Learn more! |
Change Summary
fix: enable is and isnot operator on JSON
Change type