We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PHQL wrong conversion of CAST AND CONVERT method (maybe more ?)

Hello again people !

Since 1.3.0 this PHQL query that used to work properly, doesn't now :


$di = new \Phalcon\DI\FactoryDefault();

class X extends \Phalcon\DI\Injectable
{
    public function x()
    {
        $manager = $this->getDI()->getModelsManager();
        $manager->executeQuery("SELECT id FROM Article WHERE CAST(date AS date)='2014-02-01'");
    }
}

$x = new X;
$x->setDI($di);
$x->x();

This produces this PDO query :

SELECT "article"."id" FROM "public"."article" WHERE CAST("article"."date" AS ) = '2014-02-01'

I tested with another SQL function as CONVERT and it produces exactly the same issue.

Thanks a lot !

Can you try that query with another column that is not named "date" or "datetime"? I believe those are reserved sql words.



3.2k

Hi,

thanks for the answer, actually the column name is called "date" just for the example, I could have called it "mydate", the issue is not here !