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

Update crud_exec.go #86

Closed
wants to merge 1 commit into from
Closed

Update crud_exec.go #86

wants to merge 1 commit into from

Conversation

efureev
Copy link

@efureev efureev commented Jun 14, 2019

error on case:

type User struct {
	Id        string       `json:"id" db:"id"`
	Email        string       `json:"email" db:"email"`
	Name         string       `json:"name" db:"name"`
	Photo        *string      `json:"photo" db:"photo"` // <<-- here
	Deleted      *time.Time   `json:"-" db:"deleted_at"`  // <<-- here
	CreatedAt    time.Time    `json:"-" db:"-"`
}
var item models.User
found, err := dataset.Where(goqu.I(`id`).Eq(1)).ScanStruct(&item)

Errors:

  • panic: reflect.Set: value of type reflect.Value is not assignable to type *string
  • panic: reflect.Set: value of type reflect.Value is not assignable to type *time.Time

error on case:
```
type User struct {
	Id        string       `json:"id" db:"id"`
	Email        string       `json:"email" db:"email"`
	Name         string       `json:"name" db:"name"`
	Photo        *string      `json:"photo" db:"photo"` // <<-- here
	Deleted      *time.Time   `json:"-" db:"deleted_at"`  // <<-- here
	CreatedAt    time.Time    `json:"-" db:"-"`
}
found, err := dataset.Where(goqu.I(`id`).Eq(1)).ScanStruct(&item)
```
Errors:
- panic: reflect.Set: value of type reflect.Value is not assignable to type *string
- panic: reflect.Set: value of type reflect.Value is not assignable to type *time.Time
@codecov
Copy link

codecov bot commented Jun 14, 2019

Codecov Report

Merging #86 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #86     +/-   ##
=========================================
+ Coverage   81.05%   81.16%   +0.1%     
=========================================
  Files          17       17             
  Lines        2227     2224      -3     
=========================================
  Hits         1805     1805             
+ Misses        313      312      -1     
+ Partials      109      107      -2
Impacted Files Coverage Δ
crud_exec.go 88.34% <100%> (+1.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be19636...99abe70. Read the comment docs.

@efureev
Copy link
Author

efureev commented Jun 14, 2019

DB: postgres
where, photo = NULL and deleted_at = NULL

doug-martin added a commit that referenced this pull request Jul 9, 2019
* Fix issue where structs with pointer fields where not set properly #86 and #89 - @efureev
@doug-martin doug-martin mentioned this pull request Jul 9, 2019
@doug-martin
Copy link
Owner

Fixed in pr #92. I ended up abstracting out the logic between the two cases so they use common code. I also had to change the scanner to create the pointer properly when scanning rows.

@doug-martin doug-martin closed this Jul 9, 2019
doug-martin added a commit that referenced this pull request Jul 9, 2019
* Fix issue where structs with pointer fields where not set properly #86 and #89 - @efureev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants