go-xorm / xorm

Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
BSD 3-Clause "New" or "Revised" License
6.67k stars 754 forks source link

Get ignores varchar(max) conditions for MSSQL #523

Open btrepp opened 7 years ago

btrepp commented 7 years ago

From https://github.com/go-gitea/gitea/issues/697

It appears that has, err := x.Get(&PublicKey{ Content: content, Type: KeyTypeUser, }) Where content is of type varchar(max). The content query condition is ignored. This ends up checking on the type condition, and returning incorrect values.

MSSQL does support querying on text columns. Eg the below works has, err := x.Where("content=?",content).Where("type=?",KeyTypeUser).Get(&PublicKey{})

Go-xorm should either support that in the "bean" or error out if it is not supported. Silently dropping it leads to unexpected results.

lunny commented 7 years ago

This is because MSSQL don't support use TEXT column as query condition. So xorm will ignore it.