What happens?
我在拉取 examples demo 代码后,开启sequelize-ts demo代码服务后,请求 /posts/1 接口后发生错误,而开启sequelize代码服务则是正常的
sql:
SELECT .
id,
. title
, .
content,
. user_id
, .
created_at,
. updated_at
, .
created_atAS
createdAt,
. updated_at
AS updatedAt
, .
user_idAS
userId,
user.
idAS
user.id,
user.
nameAS
user.name,
user.
ageAS
user.ageFROM
postsAS
LEFT OUTER JOIN users
AS user
ON .
user_id=
user.
idWHERE
. id
= 1;
error:
2022-02-16 00:08:44,216 ERROR 49246 [-/127.0.0.1/-/43ms GET /posts/1] nodejs.SequelizeDatabaseError: Column 'id' in field list is ambiguous
Mini Showcase Repository(REQUIRED)
examples演示代码 https://github.com/eggjs/examples/tree/master/sequelize-ts
How To Reproduce
正常拉取examples演示代码中的sequelize-ts demo,开启服务并访问post单个文章接口即可
Context
*Node Version: 16.13.2
*Egg Version: 2.33.1
*Plugin Name: egg-sequelize
*Plugin Version: 6.0.0
*typescript Version: 3.9.10
*Platform: mac
5条答案
按热度按时间vi4fp9gy1#
补充下,在我把node版本降到12.6.0后,便没有问题了,问题应该是出在node版本上
fxnxkyjh2#
我也遇到了,使用typescript + node16.x 会遇到这个问题,使用 node 14.x lts 不会
mklgxw1f3#
我也遇到了,烦死了
"egg": "^2.6.1",
"egg-jwt": "^3.1.7",
"egg-scripts": "^2.6.0",
"egg-sequelize": "^6.0.0",
"iconv-lite": "^0.6.3",
"mysql2": "^2.3.3",
"typescript": "^3.0.0"
"node":"16.14.0"
iibxawm44#
隔壁example里面有个提交有解决方案,亲测有效
https://github.com/eggjs/examples/pull/116/files/d1c949fc66f49f9795e291bf2d4684783d2b5ebb
9wbgstp75#
我也遇到了,使用typescript + node16.x 会遇到这个问题,使用 node 14.x lts 不会
隔壁example里面有个提交有解决方案,亲测有效
https://github.com/eggjs/examples/pull/116/files/d1c949fc66f49f9795e291bf2d4684783d2b5ebb