Skip to content

Accept a bare Select in Predicate::in() and notIn() - #270

Merged
simon-mundy merged 4 commits into
php-db:0.6.xfrom
simon-mundy:fix/266-in-bare-select
Dec 1, 2026
Merged

simon-mundy merged 4 commits into
php-db:0.6.xfrom
simon-mundy:fix/266-in-bare-select

Conversation

@simon-mundy

Copy link
Copy Markdown
Member

Fixes #266

Problem

Predicate::in() and notIn() type their value set as array|ArgumentInterface, so ->where->in('id', $select) is a TypeError. The In and NotIn predicates they build already accept a bare Select and wrap it in Argument\Select, and laminas-db documented array|Select for the value set.

Fix

  • in() and notIn() take array|Select|ArgumentInterface, matching In::__construct().
  • The Predicate API listing in where-having.md shows the new signatures.
  • The fluent/constructor parameter parity test now also covers notIn()'s value set.

What stays the same

  • No new wrapping code: In and NotIn already wrap the Select.
  • Passing Argument\Select explicitly works as before and produces identical SQL.

Tests

  • PredicateTest, over both methods: a bare Select renders the subquery, gives the same SQL and the same prepared parameters (:subselect1where1) as the Argument\Select form, and is stored as an Argument\Select.
  • The new tests fail with the TypeError without the fix. Unit suite: 2885 tests pass. mago lint is clean and mago analyze reports nothing new.
@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The fluent in() and notIn() typed their value set as
array|ArgumentInterface, so passing a Select for an IN (subquery)
raised a TypeError, although the In and NotIn predicates they build
accept a Select and wrap it in Argument\Select themselves. Widen both
signatures to array|Select|ArgumentInterface to match In::__construct(),
and update the Predicate API listing in the docs.

The parameter parity test now also covers notIn()'s value set.

Fixes php-db#266

Signed-off-by: Simon Mundy <simon.mundy@peptolab.com>
@simon-mundy
simon-mundy force-pushed the fix/266-in-bare-select branch from 6f0cb54 to b24b73f Compare December 1, 2026 02:39
@simon-mundy simon-mundy added this to the 0.6.0 milestone Dec 1, 2026
@github-project-automation github-project-automation Bot moved this to Todo in @phpdb Dec 1, 2026
@simon-mundy simon-mundy added bug Something isn't working documentation Improvements or additions to documentation qa Improvements in quality assurance of the project labels Dec 1, 2026
@simon-mundy simon-mundy self-assigned this Dec 1, 2026
@simon-mundy
simon-mundy requested a review from tyrsson December 1, 2026 02:52
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in @phpdb Dec 1, 2026
@simon-mundy
simon-mundy merged commit a27c5da into php-db:0.6.x Dec 1, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in @phpdb Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation qa Improvements in quality assurance of the project

2 participants