sqlstruct icon indicating copy to clipboard operation
sqlstruct copied to clipboard

Error while Scan (time.Time -> *sql.RawBytes)

Open ilgooz opened this issue 10 years ago • 2 comments

type User struct {
  Preferences *Preferences `sql:"-"`
  UpdatedAt time.Time
}

When I perform ScanAliased(&preferences) after ScanAliased(&user) I get this error right after ScanAliased(&preferences) performed:

sql: Scan error on column index 11: unsupported driver -> Scan pair: time.Time -> *sql.RawBytes

I've quickly changed this line as v = &v to avoid the issue but I'm not sure this is the correct way

ilgooz avatar Jul 04 '15 13:07 ilgooz

What's the definition of Preferences?

kisielk avatar Jul 04 '15 16:07 kisielk

Preferences struct is consist of a few string, int64, *string and bool.

Let me give you a better view of the issue. I can perform ScanAliased(&user) for select ... from users or ScanAliased(&preferences) for select ... from preferences without any issue. But when I do ScanAliased(&preferences) for select user...., preferences.... from users left join preferences... I get that error. I guess this is because it skips all the user values with &sql.RawBytes{} to reach preferences but can't skip mysql datatime with it for UpdatedAt. It works ok when I remove UpdatedAt from User struct. I can prepare a test for this if you want. Thanks!

ilgooz avatar Jul 05 '15 06:07 ilgooz