Skip to content
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

Exec.ScanStruct does not allow embedded pointers #19

Closed
ruzz311 opened this issue Jan 4, 2016 · 1 comment
Closed

Exec.ScanStruct does not allow embedded pointers #19

ruzz311 opened this issue Jan 4, 2016 · 1 comment
Labels

Comments

@ruzz311
Copy link
Collaborator

ruzz311 commented Jan 4, 2016

After working with @andymoon we discovered that ScanStruct does not allow embedded pointers in a struct. It looks like the work was completed for Exec.ScanStructs but was not applied to for the single item return.

Simple example of the issue:

package main

// ... imports ....

type testCrudActionNoTagsItem struct {
    Address string
    Name    string
}

type testEmbeddedPtrCrudActionItem struct {
    *testCrudActionItem
    PhoneNumber string `db:"phone_number"`
    Age         int64  `db:"age"`
}

func main() {
    // exec := exec.newCrudExec(...)
    embeddedPtr := &testEmbeddedPtrCrudActionItem{}
    found, err = exec.ScanStruct(&embeddedPtr)
    if err != nil {
        // This error happens:  "reflect: indirection through nil pointer to embedded struct"
        panic(err)
    }
}
@doug-martin doug-martin added the bug label Jan 4, 2016
ruzz311 added a commit to ruzz311/goqu that referenced this issue Jan 4, 2016
ruzz311 added a commit to ruzz311/goqu that referenced this issue Jan 5, 2016
ruzz311 added a commit to ruzz311/goqu that referenced this issue Jan 5, 2016
ruzz311 added a commit that referenced this issue Jan 5, 2016
Fix issue #19 - Exec.ScanStruct does not allow embedded pointers
@doug-martin
Copy link
Owner

Resolved by #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants