主键搜索无效 #1311

Closed
opened 2019-05-29 07:16:46 +00:00 by efineBai · 1 comment
efineBai commented 2019-05-29 07:16:46 +00:00 (Migrated from github.com)

代码是这样:
engine.Id(core.PK{user.Appid, user.ProviderType, user.UserName}).Get(user)
查看engine的日志发现生成的sql是这样:
[SQL] SELECT uid, appid, provider_type, create_at, time_zone, country, language, email, user_name, firstname, lastname, endpoint_type, email_login, facebook_login, birthdate, age, gender, pwd, ip FROM user_info WHERE appid=? AND provider_type=? AND time_zone=? AND language=? AND user_name=? AND endpoint_type=? AND ip=? AND appid=? AND provider_type=? AND user_name=? LIMIT 1 []interface {}{1231231231, "email", 14, "ms", "XXX@foxmail.com", "web", "1.1.1.1", 1231231231, "email", "XXX@foxmail.com"} - took: 358.62µs

实际执行的sql中将所有字段都加了进去,按文档说明应该是只搜索主键,请各位大佬帮忙看下

代码是这样: engine.Id(core.PK{user.Appid, user.ProviderType, user.UserName}).Get(user) 查看engine的日志发现生成的sql是这样: [SQL] SELECT `uid`, `appid`, `provider_type`, `create_at`, `time_zone`, `country`, `language`, `email`, `user_name`, `firstname`, `lastname`, `endpoint_type`, `email_login`, `facebook_login`, `birthdate`, `age`, `gender`, `pwd`, `ip` FROM `user_info` WHERE `appid`=? AND `provider_type`=? AND `time_zone`=? AND `language`=? AND `user_name`=? AND `endpoint_type`=? AND `ip`=? AND `appid`=? AND `provider_type`=? AND `user_name`=? LIMIT 1 []interface {}{1231231231, "email", 14, "ms", "XXX@foxmail.com", "web", "1.1.1.1", 1231231231, "email", "XXX@foxmail.com"} - took: 358.62µs 实际执行的sql中将所有字段都加了进去,按文档说明应该是只搜索主键,请各位大佬帮忙看下

If your user has non-empty field value, it also will be as conditions. You can use an empty user(just new(User)) or you can be with NoAutocondition().Get(user).

If your user has non-empty field value, it also will be as conditions. You can use an empty user(just new(User)) or you can be with `NoAutocondition().Get(user)`.
lunny closed this issue 2020-06-04 01:40:33 +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#1311
No description provided.