Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

TableGateway delete(), insert() and update() raise TypeError for an aliased table

Offen
#209 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@simon-mundy arbeitet bereits daran.

Seit 05.10.2026.

  • #225 von @simon-mundy — offen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
30/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
php, sql
Bereich
databases

Rechercherichtung

Start with TableGateway's delete(), insert(), and update() methods, then compare them with executeDelete(), executeInsert(), and executeUpdate() in AbstractTableGateway.php. Read the referenced Sql.php and Delete.php, Insert.php, and Update.php constructors and setters; the existing gateway alias tests mock Sql and miss this path. Add coverage using an aliased TableGateway and verify the generated data-changing statements target the bare table; also check the open linked pull request before starting.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug
Package Version

0.6.x-dev @ e022af5c

Php Version

8.3, 8.4, 8.5

Database Engine

Any

Basic Information

TableGateway supports an aliased table (['u' => 'users'] or ['u' => new TableIdentifier(...)]). Its executeDelete(), executeInsert() and executeUpdate() swap in the bare table before rendering, then restore the array, because most databases reject aliases in INSERT, UPDATE and DELETE (AbstractTableGateway.php#L276-L292; laminas zf2#7311, PR #342).

That swap is never reached through the gateway's own methods. delete(), insert() and update() call Sql::delete() / insert() / update() (Sql.php#L49, #L78, #L124). Those pass the aliased array to the Delete, Insert and Update constructors, which accept only string|TableIdentifier|null (Delete.php#L48, Insert.php#L54, Update.php#L70). Their setters from(), into() and table() do accept arrays.

Rendering a statement that holds an aliased array also raises a TypeError, since AbstractSql::resolveTable() takes no arrays.

The constructors were narrowed in 4807d3c9 ("Strong typing and rector improvements"). The gateway's alias tests mock Sql, so they do not exercise this path.

Steps to Reproduce
  1. new TableGateway(['u' => 'users'], $adapter), then ->delete(['id' => 5]), ->insert(['id' => 5]) or ->update(['n' => 'x'], ['id' => 5]).
Expected Behavior

DELETE FROM "users" WHERE "id" = ? and the equivalent INSERT and UPDATE against the bare table, matching what executeDelete() and friends intend. select() keeps the alias.

Actual behavior?
TypeError: PhpDb\Sql\Delete::__construct(): Argument #1 ($table) must be of type PhpDb\Sql\TableIdentifier|string|null, array given
Additional Info

The unmerged sql-platform-refactor branch removes the gateway's unaliasing and renders aliases in data-changing statements (b4180743). That is the opposite of the expected behaviour above, and it would need reconciling if revived.

Vorherrschende Sprache
PHP
Sterne
18
Forks
8
Ø Merge
6 T. 11 Std.
Gemergte PRs (30 T.)
14

Entwicklungsumgebung

  • Enthält ein Dockerfile oder eine Docker-Compose-Datei
  • Keine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus php-db/phpdb

Alle Issues in php-db/phpdb

Ähnliche Issues

Weitere Issues zu PHP

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.