nette / database

💾 A database layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.
https://doc.nette.org/database
Other
513 stars 108 forks source link

Unexpected type of parameter: array #267

Closed nargotik closed 3 years ago

nargotik commented 3 years ago

Version: 3.1.0

Bug Description

After updating from 3.0.7 to 3.1.0 some code started to give error:


$where[] =  $database::literal('?or', [
            [
                $database::literal("name LIKE ? ", $name )
            ],
        ]);
`
dg commented 3 years ago

Version 3.1 points out some mistakes that could have been made before. I think in your case there are extra brackets, it should be

$database::literal('?or', [
            $database::literal("name LIKE ? ", $name )
]);
nargotik commented 3 years ago

I will try out tonight, the case that the code I have posted was incomplete.

$where[] =  $database::literal('?or', [
            [
                $database::literal("name LIKE ? ", $name )
            ],
            [
                $database::literal("rule2 LIKE ? ", $name )
            ],
        ]);

I would try:

$where[] =  $database::literal('?or', [
                $database::literal("name LIKE ? ", $name ),
                $database::literal("rule2 LIKE ? ", $name ),
        ]);

and

$where[] =  $database::literal('?or', [
                [$database::literal("name LIKE ? ", $name ),$database::literal("subruleand LIKE ? ", $name )]
                $database::literal("rule2 LIKE ? ", $name ),
        ]);
nargotik commented 3 years ago

You have reason, correcting array solved the problem :+1: