Get ignores varchar(max) conditions for MSSQL #523

Closed
opened 2017-01-19 03:15:26 +00:00 by btrepp · 2 comments
btrepp commented 2017-01-19 03:15:26 +00:00 (Migrated from github.com)

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.

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.

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

This is because MSSQL don't support use `TEXT` column as query condition. So xorm will ignore it.
lunny modified the milestone from 0.8.2 to 1.1.1 2020-02-21 02:52:12 +00:00
lunny modified the milestone from 1.1.1 to 1.3.0 2021-06-07 07:45:26 +00:00

Maybe we should give an error clearly.

Maybe we should give an error clearly.
lunny added
kind
enhancement
and removed
kind
feature
labels 2021-10-20 00:56:55 +00:00
lunny modified the milestone from 1.3.0 to 1.3.1 2022-03-31 06:29:19 +00:00
lunny closed this issue 2022-04-23 09:19:38 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#523
No description provided.