Skip to content

Feature request: extend Strict Scan mode to also detect unmapped struct fields #472

Open
@kblomster

Description

@kblomster

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:

var target []struct {
	Foo string
	Bar int
}
stmt := jet.SELECT(
	jet.String("hello").AS("foo"))
// panic: target is not fully populated, missing field Bar
err := stmt.Query(db, &target)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions