使用Join时Find函数里面的条件并没有加入到sql语句中 #1009

Open
opened 2018-06-19 06:21:45 +00:00 by willkk · 2 comments
willkk commented 2018-06-19 06:21:45 +00:00 (Migrated from github.com)

问题:
DbEngine.Join("INNER", "device_app", "device.sn=device_app.sn").
Join("INNER", "app", "app.id=device_app.app_id").
Desc("app.id").Limit(limit, start).Find(&devs, orm.Device{Sn: req.Sn})
打印出来的语句:
SELECT * FROM device INNER JOIN device_app ON device.sn=device_app.sn INNER JOIN app ON app.id=device_app.app_id ORDER BY app.id DESC LIMIT 1 OFFSET 1

问题: DbEngine.Join("INNER", "device_app", "device.sn=device_app.sn"). Join("INNER", "app", "app.id=device_app.app_id"). Desc("app.id").Limit(limit, start).Find(&devs, orm.Device{Sn: req.Sn}) 打印出来的语句: SELECT * FROM device INNER JOIN device_app ON device.sn=device_app.sn INNER JOIN app ON app.id=device_app.app_id ORDER BY app.id DESC LIMIT 1 OFFSET 1

@willkk could you confirm that req.Sn is not blank?

@willkk could you confirm that `req.Sn` is not blank?
willkk commented 2018-06-19 08:32:44 +00:00 (Migrated from github.com)

req.Sn is not empty. I check req.Sn before using it.

req.Sn is not empty. I check req.Sn before using it.
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#1009
No description provided.