top-think / top-think/think-orm

think-orm v2.0.33 多对多关联 报错pivot不是唯一

Open
#180 2 comments 0 reactions 0 assignees View on GitHub

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后报错了

执行查询
image

模型定义
image

环境:
"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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.