top-think / top-think/think-orm

一对多关联字段查询BUG

Open
#504 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

https://github.com/top-think/think-orm/blob/7b0b8ea6ca5e020217f6ba7ae34d547e148a675b/src/model/relation/HasManyThrough.php#L270

如果表有前缀就会报错,直接获取表明也不是个问题啊;再或者表明和模型名不一样也是有问题

if ($this->baseQuery) {
            $throughKey = $this->query->getTable()  . '.' . $this->throughKey;
        }

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/HasManyThrough.php around line 270 and inspect how the through table is obtained when baseQuery is present. Reproduce the relation query with a table prefix and with a table name that differs from the model name; done means both cases resolve the correct table and no longer raise an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.