Beego: Ormer.Read() and RawSeter.QueryRow() handle pointers differently

Created on 10 Sep 2015  ·  6Comments  ·  Source: astaxie/beego

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.

Most helpful comment

@astaxie @slene So QuerySeter and RawSeter handle pointers differently. Would this be hard to fix?

All 6 comments

me too ....

[email protected]

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.

3519

Is it alright to think that this was solved?

I have no idea. Stopped using this years ago.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DemonsLu picture DemonsLu  ·  4Comments

drmaples picture drmaples  ·  6Comments

patrick-fitzgerald picture patrick-fitzgerald  ·  3Comments

osavchenko picture osavchenko  ·  4Comments

zhiquan911 picture zhiquan911  ·  4Comments