TableGateway delete(), insert() and update() raise TypeError for an aliased table
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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ả
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
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của php-db/phpdb
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RFC
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RFC
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RFC
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RFC
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
customer-support needs-triage Platform(Default)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
grokability/snipe-it#19767 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Code Quality] SfxDownloader extract path has no destination-writability pre-check for cached zipsĐang mởpriority:low type:refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
crazy-goat/workerman-bundle#1052 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày