Skip to content

[Bug]: withDriver() without a prefix breaks sqlStatement() #307

Open

Description

@roxblnfk

Describe the bug

ActiveQuery::withDriver($driver) without a prefix leaves the query unusable. The $prefix parameter defaults to null and is stored as is (src/Query/ActiveQuery.php:33), but the compiler later expects a string prefix, so a subsequent sqlStatement() fails.

Is this a regression?

Not checked.

To Reproduce

  1. $query = (new SelectQuery())->from('users')->withDriver($driver);
  2. $query->sqlStatement();
  3. TypeError from the compiler (string expected, null given).

Expected behaviour

No prefix means an empty prefix: store $prefix ?? '', or make the parameter default to ''.

Media prove

Not applicable.

Database

All of them.

Your environment

cycle/database 2.x, src/Query/ActiveQuery.php:29-36.

Additional context

Found while raising coverage in #304. A related crash, where('x', 'between', $a, <subquery or fragment>) throwing TypeError in Compiler::condition(), is mentioned in #300.

Activity

  1. added
    status:to be verified
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:to be verifiedtype:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions