decimal icon indicating copy to clipboard operation
decimal copied to clipboard

Json deconing throws nil dereference

Open eduardhasanaj opened this issue 6 years ago • 7 comments

Hi, I am seeing and error from this lib at this line github.com/ericlagergren/[email protected]/scan.go:43 +0x9e The error occurred when using json decoder on a model generated by sqlboiler.

eduardhasanaj avatar Oct 05 '19 16:10 eduardhasanaj

Could you post a code same that I could use to reproduce this? The panic on line 43 is ostensibly because the recover is nil, which is likely due to the generated code. I’m not familiar with sqlboiler.

ericlagergren avatar Oct 05 '19 16:10 ericlagergren

I am sorry for not providing the code.

type Option struct {
	ID           int               `boil:"id" json:"id" toml:"id" yaml:"id"`
	OptionlistID null.Int          `boil:"optionlist_id" json:"optionlist_id,omitempty" toml:"optionlist_id" yaml:"optionlist_id,omitempty"`
	Description  null.String       `boil:"description" json:"description,omitempty" toml:"description" yaml:"description,omitempty"`
	Price        types.NullDecimal `boil:"price" json:"price,omitempty" toml:"price" yaml:"price,omitempty"`

	R *optionR `boil:"-" json:"-" toml:"-" yaml:"-"`
	L optionL  `boil:"-" json:"-" toml:"-" yaml:"-"`
}

If I invoke scan on the Price before decoding I do not get the error. The problem is that I need this to decode an array

eduardhasanaj avatar Oct 05 '19 18:10 eduardhasanaj

Hm. Sounds similar to https://github.com/volatiletech/sqlboiler/issues/404. Perhaps I should revisit that issue.

ericlagergren avatar Oct 05 '19 19:10 ericlagergren

I've corrected this as ericlagergren suggested in his PR to sqlboiler. Will be in the dev branch for now and included in a later release.

aarondl avatar Oct 09 '19 16:10 aarondl

Hi @aarondl , do we have an update about this issue? If this is already fixed, do we know already when it will be merged?

jbactad avatar Dec 09 '19 10:12 jbactad

@jbactad Hi, Currently I am using dev branch for this problem.

eduardhasanaj avatar Dec 09 '19 15:12 eduardhasanaj

@jbactad As far as I'm concerned this is fixed already in master v3.6.0

aarondl avatar Dec 14 '19 18:12 aarondl