Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Sql's foreign-table guard raises TypeError when its table is a TableIdentifier or aliased array

Aberta
#210 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@simon-mundy já está trabalhando nisso.

Desde 5/10/2026.

  • #226 de @simon-mundy — aberto

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
50/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
php
Domínio
databases

Direção de pesquisa

The TypeError originates in src/Sql/Exception/InvalidArgumentException::forForeignTable() at line 114, which expects a string but receives $this->table from src/Sql/Sql.php. Examine the four call sites in Sql.php (delete, insert, select, update) and the TableIdentifier class to understand how to convert table representations to strings. The fix should produce messages like 'app.users' for TableIdentifier and 'users AS u' for aliased arrays. Run the test suite, particularly any Sql or InvalidArgumentException tests, to verify the exception message format.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug
Package Version

0.6.x-dev @ e022af5c

Php Version

8.3, 8.4, 8.5

Database Engine

Any

Basic Information

Sql::delete(), insert(), select() and update() throw when asked for a table other than the one Sql was constructed with (Sql.php#L46, #L75, #L102, #L121). Each passes $this->table to forForeignTable(string $table) (InvalidArgumentException.php#L114). Sql's table can be a TableIdentifier or an aliased array, and either raises a TypeError while building the exception.

#192 notes this as needing its own issue: "TableIdentifier has no __toString(), so Sql::forForeignTable($this->table) fatals when $this->table is a TableIdentifier".

Steps to Reproduce
  1. new Sql($adapter, new TableIdentifier('users', 'app')), then ->select('other').
  2. new Sql($adapter, ['u' => 'users']), then ->select('other').
Expected Behavior

PhpDb\Sql\Exception\InvalidArgumentException with a message naming the table: app.users for a TableIdentifier, and users AS u for an aliased array.

Actual behavior?
TypeError: PhpDb\Sql\Exception\InvalidArgumentException::forForeignTable(): Argument #1 ($table) must be of type string, PhpDb\Sql\TableIdentifier given
Linguagem predominante
PHP
Estrelas
18
Forks
8
Merge médio
6d 11h
PRs com merge (30d)
14

Preparar o ambiente

  • Inclui um Dockerfile ou arquivo Docker Compose
  • Sem modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de php-db/phpdb

Todas as issues de php-db/phpdb

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.