Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#209 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@simon-mundy đang làm issue này rồi.

Từ ngày 5/10/2026.

  • #225 của @simon-mundy — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php, sql
Lĩnh vực
databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
PHP
Star
18
Fork
8
Merge trung bình
6 ngày 11 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của php-db/phpdb

Tất cả issue của php-db/phpdb

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.