cycle / database

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
MIT License
53 stars 22 forks source link

πŸ› Incorrect insertion of FragmentInterface parameters into WHERE IN queries #145

Closed iGrog closed 7 months ago

iGrog commented 7 months ago

No duplicates πŸ₯².

Database

MySQL

What happened?

A bug happened!

FragmentInterface parameters are not functioning properly in WHERE IN queries:

    // $guid implements FragmentInterface
    $guid1 = Guid::fromString('0189a22f-1bd0-7005-959a-46860de7d841');
    $guid2 = Guid::fromString('015033e7-a2f0-9ad2-fa9e-e075f4d07a6a');
    $ids = [$guid2]; 
    $select = $this->repository
            ->select()
            ->where('categoryGuid', $guid1);
            ->andWhere('someGuid', 'IN', new Parameter($ids))
            ->fetchData();

Actual behavior:

WHERE `CategoryGuid` = UUID_TO_BIN('018c11c6-0cae-725e-b885-499e53e8ec5f') 
AND SomeGuid` IN ('018c11c6-5657-7fdc-b2fd-7a6909c1683f') 

Expected behavior:

All FragmentInterface objects correctly inserted into the query (added UUID_TO_BIN also in IN parameters)

WHERE `CategoryGuid` = UUID_TO_BIN('018c11c6-0cae-725e-b885-499e53e8ec5f') 
AND SomeGuid` IN (UUID_TO_BIN('018c11c6-5657-7fdc-b2fd-7a6909c1683f')) 

Version

database 2.0
PHP 8.2