top-think / top-think/think-orm

v4.0.51模型多对多关联超过一定数量报错

Open
#847 3 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

会员表ya_member:member_id,nickname;
会员标签表ya_member_tag:tag_id,tag_name;
会员标签关联表ya_member_attributes:id,member_id,tag_id;

模型多对多关联查询

$list  = $model->with($with)->page($page)->limit($limit)->append($append)->hidden($hidden)->group($group)->order($order)->select()->toArray();

当limit等于300是正常的;超过300的时候会报错(具体数值未知,因为分页数量设置了只能选...300,500,800,1000):

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'tag_id' in where clause is ambiguous;

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

Start by reproducing the many-to-many query with the ya_member, ya_member_tag, and ya_member_attributes tables, comparing limit 300 with values above 300. Trace the generated query around the with(), page(), limit(), and toArray() calls; done means larger page sizes no longer produce the ambiguous tag_id error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.