Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: @koishijs/plugin-database-mysql 升级后出现 Every derived table must have its own alias #1259

Closed
shumyun opened this issue Nov 8, 2023 · 2 comments
Labels
bug BUG

Comments

@shumyun
Copy link

shumyun commented Nov 8, 2023

Describe the bug

使用4.15.0版本时不会出现问题,这次升级4.15.4 时就出现问题:
源代码为
const count = await this.ctx.database.select('platform').where({ pid: 1, publish: { $ne: 1 }, }).execute((row) => $.count(row.id));
提示错误:
2023-11-08 20:05:34 [W] mysql > SELECT count(distinct id) AS value FROM (SELECT id, pid, mid, publish, time, data FROM ‘platform’ zgkjgyjb WHERE pid = 1 AND publish != 1)
2023-11-08 20:05:34 [W] ESV.upload uploading BD : Error: ER_DERIVED_MUST_HAVE_ALIAS: Every derived table must have its own alias
为什么会出现这个 zgkjgyjb 这个乱码

Steps to reproduce

Expected behavior

Screenshots

No response

Versions

  • OS:
  • Platform:
  • Node version:
  • Koishi version:

Additional context

No response

@shumyun shumyun added the bug BUG label Nov 8, 2023
@shumyun
Copy link
Author

shumyun commented Nov 8, 2023

忘记说了。现在用的 @koishijs/plugin-database-mysql 的版本是 5.5.5
之前用的版本不记得,是4.15.0 自带安装的。
目前解决的方案是
const _data = await this.ctx.database.select('platform').where({ pid: 1, publish: { $ne: 1 },}).execute();
获取所有数据后,再使用 _data.length ;这样没问题!

@shigma
Copy link
Member

shigma commented Nov 13, 2023

Fixed by cordiverse/minato@9208ce5

@shigma shigma closed this as completed Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug BUG
Projects
None yet
Development

No branches or pull requests

2 participants