我正在使用带有 mariadb 方言的 Sequelize v6。
我有如下查询:
db.RunVersion.findAll({
include: [{
model: db.Run,
include: [{
as: "Watchers",
model: db.RunWatchers,
required: true,
where: {id: user.id}
}],
}],
where: where
}]
这会产生一个 WHERE 子句,如下所示:
FROM RunVersions AS RunVersion
LEFT OUTER JOIN (Runs AS Run
INNER JOIN RunWatchers AS Runs->Watchers ON Run.id = Run->Watchers.wid
AND Run->Watchers.un = 'mrprice') ON RrunVersion.rid = Run.id
这会返回不好的结果。我希望 WHERE 子句看起来像这样:
FROM RunVersions AS RunVersion
LEFT OUTER JOIN Runs AS Run ON RunVersion.rid = Run.id
INNER JOIN RunWatchers AS Run->Watchers ON Run.id = Run->Watchers.wid AND Run-Watchers.unname = 'mrprice'
任何想法为什么会发生这种情况?