cycle / database

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
MIT License
54 stars 23 forks source link

🐛 Incorrect insertion of FragmentInterface parameters into WHERE IN queries #164

Open iGrog opened 6 months ago

iGrog commented 6 months ago

No duplicates 🥲.

Database

MySQL

What happened?

Continue of #145

$products = $this->select()->andWhere('productGuid', 'IN', $productGuids)->fetchData();

with empty array $productGuids resulting the following sql:

AND `xxx`.`ProductGuid` IN() 

and database error is raised, as there is nothing in IN

Version

database 2.8.1
PHP 8.3
roxblnfk commented 6 months ago

Hi. What do you expect from ORM in case of passing an empty list?

iGrog commented 6 months ago

Hi, maybe not to generate AND xxx.ProductGuid IN() at all?

roxblnfk commented 6 months ago

Hi, maybe not to generate AND xxx.ProductGuid IN() at all?

or generate FALSE instead? because the IN operator is used to define a white list. And if the list is empty it equals to FALSE

roxblnfk commented 6 months ago

Yet another option -- generate xxx.ProductGuid is null. Wny not? The values list has no values. Shouldn't we check that field has no value too? :)