top-think / top-think/think-orm

[Bug] 多对多关系时无法正确 new Pivot 对象

Open
#327 0 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

BelongsToMany.php#L105 传递参数错误

TypeError: Argument 1 passed to think\model\Pivot::__construct() must be an instance of think\Model or null, array given

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 at src/model/relation/BelongsToMany.php line 105 and inspect the arguments passed when creating a think\model\Pivot instance. Compare them with the constructor signature and trace the many-to-many relation path that reaches this call. Done means the relation can create the Pivot object without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.