type Foo struct {
ID int `orm:"pk;auto;column(id)"`
Text *string
}
Ormer.Read(id) works well, but orm.Raw("SELECT * FROM foos where id=$1", id).QueryRow(&foo) always returns foo.Text as nil. Even when foo.text != NULL in the database.
me too ....
From: Paul Tötterman
Date: 2015-09-10 19:12
To: astaxie/beego
Subject: [beego] Ormer.Read() and RawSeter.QueryRow() handle pointers differently (#1356)
type Foo struct {
ID int orm:"pk;auto;column(id)"
Text *string
}
Ormer.Read(id) works well, but orm.Raw("SELECT * FROM foos where id=$1", id).QueryRow(&foo) always returns foo.Text as nil. Even when foo.text != NULL in the database.
—
Reply to this email directly or view it on GitHub.
@astaxie What do you think? bf429a3a20538dc6f7f47a45cfe700551ed0c440 added _really_ nice support for pointer fields. I much prefer *string to NullString. But *string only works with .Read() and .All(), but not raw queries ( .QueryRows() ). Can it be fixed or what should we do?
@astaxie @slene So QuerySeter and RawSeter handle pointers differently. Would this be hard to fix?
sql.NullInt64 does not work for me with .Raw() as *Int64 (field is always NULL) . But both variants work with All(). Seems like there is no way to run custom sql-select for beego models.
Is it alright to think that this was solved?
I have no idea. Stopped using this years ago.
Most helpful comment
@astaxie @slene So QuerySeter and RawSeter handle pointers differently. Would this be hard to fix?