top-think / top-think/think-orm
think-orm v2.0.33 多对多关联 报错pivot不是唯一
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
多对多关联 报错 pivot不是唯一:
出错版本 topthink/think-orm": "2.0.33" 出现以下问题,但是2.0.33之前的版本没有问题。
错误:SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'pivot'
@liu21st @yunwuxin @vus520 @Lofanmi 请大佬们帮忙检查以下原因?升级2.0.33后报错了
执行查询

模型定义

环境:
"php": "7.4.8",
"topthink/framework": "6.0.3"
"topthink/think-orm": "2.0.33"
mysql=8.0.x
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report names no repository files or tests. Reproduce the many-to-many query with PHP 7.4.8, MySQL 8.0.x, think-orm 2.0.33, and the provided model definitions, then compare it with a pre-2.0.33 version. Done means the query no longer produces the duplicate pivot alias error and the regression is covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100