golang gorp select with nullString fail

316 Views Asked by At

I define order struct like t

type Order struct {
    Id      nullString `db:"O_ID"`
    CusTel  int64      `db:"O_CUS_TEL"`
}

And I installed a Order object as order, when I called: dbmap.SelectInt("SELECT count(*) FROM ORDERS WHERE O_ID=?",o.Id) i got such error:

[gorp] SELECT count(*) FROM ORDERS WHERE O_ID=? []
Search order by id:{{00000001 true}} fail:Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1

But if i use it like that:

dbmap.Db.Exec("SELECT count(*) FROM ORDERS WHERE O_ID=?",o.Id)

It`s done.

I don`t know why?

0

There are 0 best solutions below