Uh oh!
There was an error while loading. Please reload this page.
fix(builder/parser): correct JSON filtering and deterministic filter order - #40
Conversation
This comment has been minimized.
This comment has been minimized.
The new buildJSONClause method constructs raw SQL clauses with LIKE/NOT LIKE operators via conditionBuilderDB.Where(...) without a context timeout, allowing queries to run indefinitely. Add Kody rule violation: Disallow GORM queries without timeout |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Code Coverage ReportTotal Coverage: 88.8% Generated from commit: 569e0e7 |
This comment has been minimized.
This comment has been minimized.
The added line at 184 uses Kody rule violation: Disallow GORM queries without timeout |
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
02c9e84 to
d430849Compare
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
d430849 to
ca70e06Compare
This comment has been minimized.
This comment has been minimized.
ca70e06 to
a010be8CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a010be8 to
2d22c00Compare
This comment has been minimized.
This comment has been minimized.
The new Kody rule violation: Disallow GORM queries without timeout |
Uh oh!
There was an error while loading. Please reload this page.
2d22c00 to
9e2b0f0Compare
This comment has been minimized.
This comment has been minimized.
In Kody rule violation: Disallow GORM queries without timeout |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9e2b0f0 to
4001828Compare
This comment has been minimized.
This comment has been minimized.
4001828 to
8ecdee8CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Fix MySQL JSON_EXTRACT returning quoted strings by wrapping in JSON_UNQUOTE - Quote non-identifier JSON path segments for MySQL compatibility - DRY operator maps into dialectPattern descriptors with precomputed lookups - Detect MariaDB vs MySQL via SELECT VERSION(), cache on root *sql.DB - Make dialect resolution lazy so ApplySort pays no DB round-trip - ApplySort no longer constructs a GORMBuilder - Sort filter map keys for deterministic serialization - Add dialect detection and operator map unit tests
8ecdee8 to
011dda2CompareKody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Uh oh!
There was an error while loading. Please reload this page.
Fixes JSON pattern matching on MySQL by unquoting extracted string values and applying an explicit case-insensitive collation, aligning behavior with SQLite.
Makes QueryParamParser emit filters in deterministic key order, removing an intermittent serializer failure caused by randomized Go map iteration.
Resolves pre-existing failures in the json_startswith_filter, json_not_contains_case-sensitive_filter, and json_field_with_explicit_null_value tests while preserving backwards-compatible OpNull semantics.
Based on the code changes, this pull request addresses two main issues:
Summary
This PR fixes JSON filtering behavior across different database dialects and ensures deterministic filter ordering in query parameter parsing.
Key Changes
1. Fixed JSON Filtering for MySQL/MariaDB Pattern Matching
Problem: MySQL's
JSON_EXTRACT()function preserves surrounding quotes on string values, which breaks pattern matching operations (e.g.,LIKE 'dar%'would fail against"dark"instead of matchingdark).Solution:
jsonExtractExpr()helper method that wraps MySQL/MariaDBJSON_EXTRACT()inJSON_UNQUOTE()to strip quotes and match SQLite'sjson_extract()behaviorCOLLATE utf8mb4_0900_ai_ci) to LIKE operations to match SQLite's default case-insensitive behavior2. Fixed Non-Deterministic Filter Ordering
Problem: Go map iteration order is randomized, causing inconsistent filter application order when parsing query parameters.
Solution: Added sorting of map keys before building filters to ensure deterministic, reproducible filter ordering based on alphabetical key order.
3. Corrected NULL JSON Path Filtering Test
Updated test expectations to correctly reflect that
OpNullmatches missing JSON paths (treating them as NULL), consistent with documented JSON null filtering behavior.4. Code Cleanup