top-think / top-think/think-orm

远程一对一多关联,表名称不全导致查询sql出错

Open
#381 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/e1974a4c3b1b4c5b808fcc0863fc254e711dee13/src/model/relation/HasManyThrough.php#L264

if ($this->baseQuery) {
$throughKey = Str::snake(class_basename($this->model)) . "." . $this->throughKey;
}

Str::snake(class_basename($this->model)) 只能得到没有前缀的表名,如果有前缀那不是错了;现在使用远程一对多关联直接报错;没更新之前还是好的,这么改是为什么呢

image

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 points to src/model/relation/HasManyThrough.php around line 264, where the through key is assembled for a remote one-to-many relation. Start by reproducing the failing query with a configured table prefix and inspect the generated SQL. Done means the relation query works with prefixed table names without SQL errors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.