Repository navigation
Accept an aliased-table array in Sql::select() - #272
Merged
simon-mundy merged 10 commits intoDec 1, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Sql::select() typed its table as string|TableIdentifier|null, so $sql->select(['f' => 'foo']) raised a TypeError, although the Select constructor and from() accept the [alias => table] form and laminas-db rendered it. Widen the parameter to match, so the call renders SELECT "f".* FROM "foo" AS "f" again. update() and delete() are left as they are: their statements render the bare table and drop the alias, and laminas-db never rendered an aliased update or delete either. Fixes php-db#271 Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
simon-mundy
force-pushed
the
fix/271-select-aliased-table
branch
from
December 1, 2026 02:39
7ec39d8 to
d22fb49
Compare
Signed-off-by: Simon Mundy <46739456+simon-mundy@users.noreply.github.com>
Signed-off-by: Simon Mundy <46739456+simon-mundy@users.noreply.github.com>
Signed-off-by: Simon Mundy <46739456+simon-mundy@users.noreply.github.com>
Signed-off-by: Simon Mundy <46739456+simon-mundy@users.noreply.github.com>
tyrsson
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #271
Problem
Sql::select()types its table asstring|TableIdentifier|null, so$sql->select(['f' => 'foo'])is aTypeError.new Select(['f' => 'foo'])and->from(['f' => 'foo'])accept the[alias => table]form, and laminas-db'sSql::select()rendered it.Fix
Sql::select()takesarray|string|TableIdentifier|null, matching theSelectconstructor, with a@paramdescribing the array shape.What stays the same
update()anddelete(). Their statements keep an aliased table only for TableGateway and render the bare table, so widening them would letSqlbuild SQL the database rejects. laminas-db never rendered an aliased update or delete either (it producedUPDATE `Array`with a warning).forForeignTable()already accepts the array form.Tests
SqlTest:select(['f' => 'foo'])returns aSelectwith that table, rendersSELECT "f".* FROM "foo" AS "f", and still throws when theSqlobject has a fixed table.SqlTestalso gains its#[Group('unit')].mago lintis clean andmago analyze(1.62.0) reports only the findings already on 0.6.x.