You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I was very happy to see the addition of Strict Scan mode in 2.13. It catches a relatively common type of mistake that we can't really catch in any other way.
There is a closely related problem that it does not catch, though - it catches the case where you're projecting columns that you end up not using, but it does not catch the case where the data structure you're mapping into is not being fully populated by the projections. At least in our codebase, this reverse problem is actually a bigger pain point because the Go zero values for structs are very good at concealing this problem.
We really love Jet, but one of our biggest pain points is actually how inscrutable the QRM appears, especially to people new to Jet. You get zero feedback from it, it just silently hands you structs with the wrong data in them.
Describe the solution you'd like
I'd love to see a Strict Scan-like feature that will panic and/or make some other noise if the mapping target is not fully populated by the query. Trivial example:
vartarget []struct {
FoostringBarint
}
stmt:=jet.SELECT(
jet.String("hello").AS("foo"))
// panic: target is not fully populated, missing field Barerr:=stmt.Query(db, &target)
The text was updated successfully, but these errors were encountered:
kblomster
changed the title
Extend Strict Scan mode to also detect unmapped struct fields
Feature request: extend Strict Scan mode to also detect unmapped struct fields
Mar 25, 2025
As code of interest - at this line unuesed field is identified.
And for the tests - we can set this new StrictFieldMapping flag for either mysql or sqlite tests, since postgres tests are already run in StrictScan mode.
Is your feature request related to a problem? Please describe.
I was very happy to see the addition of Strict Scan mode in 2.13. It catches a relatively common type of mistake that we can't really catch in any other way.
There is a closely related problem that it does not catch, though - it catches the case where you're projecting columns that you end up not using, but it does not catch the case where the data structure you're mapping into is not being fully populated by the projections. At least in our codebase, this reverse problem is actually a bigger pain point because the Go zero values for structs are very good at concealing this problem.
We really love Jet, but one of our biggest pain points is actually how inscrutable the QRM appears, especially to people new to Jet. You get zero feedback from it, it just silently hands you structs with the wrong data in them.
Describe the solution you'd like
I'd love to see a Strict Scan-like feature that will panic and/or make some other noise if the mapping target is not fully populated by the query. Trivial example:
The text was updated successfully, but these errors were encountered: