-
-
Notifications
You must be signed in to change notification settings - Fork 171
feat: add StrictFieldMapping config #542
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #542 +/- ##
==========================================
+ Coverage 92.19% 92.22% +0.02%
==========================================
Files 139 139
Lines 8584 8638 +54
==========================================
+ Hits 7914 7966 +52
- Misses 493 495 +2
Partials 177 177 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b163c23 to
f33c2ee
Compare
| // This check applies only to fields that are mapped from a single column (simple/scanner/json_column). | ||
| // Complex fields (struct/slice) are excluded because they are not mapped from a single column. |
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.
❓ These two comment lines are outdated now, aren't they?
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.
Yeah, those two lines can be removed.
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.
I think those two comment lines are still valid.
if fieldMap.Type == complexType {
return false
}The purpose of qrm:"optional" is simply to suppress unmapped-field reporting for fields under an optional parent (often a complex struct/slice field), not to make complexType fields themselves part of the StrictFieldMapping checks. If I’m misunderstanding anything, please let me know.
fix #472
Added a new qrm configuration flag
StrictFieldMappingto detect destination struct fields (single-column mapped fields only) that have no matching columns in the SQL result set and panic when enabled.Updated tests/sqlite to allow per-test toggling and added test cases verifying the behavior for full-column vs partial-column SELECTs under StrictFieldMapping on/off.