Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] PHQL statement with CAST AND CONVERT (maybe others) functions are badly converted into SQL #2229

Closed
jimjim2a opened this issue Mar 24, 2014 · 2 comments
Labels
bug A bug report status: medium Medium

Comments

@jimjim2a
Copy link
Contributor

Hello,

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

<?php
$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(mycolumn 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"."mycolumn" AS ) = '2014-02-01'

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

I don't know if it is important or not, but my RDBMS is PostgreSql.

I have opened a discussion about this issue in the forum by the way ( http://forum.phalconphp.com/discussion/1863/phql-wrong-conversion-of-cast-and-convert-method-maybe-more- )

Thanks a lot !

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@jimjim2a
Copy link
Contributor Author

Another issue :

I used to make queries with DISTINCT clauses IN 1.2.6 with succes.

But it seems that the DISTINCT clause in either PHQL (or using find method) doesn't work anymore. (since 1.3.0) :

$rows = $this->modelsManager->executeQuery("SELECT DISTINCT type AS type FROM MyModel");

It produces :

SELECT "mymodel"."type" AS "type" FROM "public"."mymodel"

phalcon pushed a commit that referenced this issue Apr 6, 2014
fix issue #2229 (cast and convert not working)
@Green-Cat
Copy link
Contributor

@andresgutierrez Fixed in #2307

@phalcon phalcon closed this as completed May 25, 2015
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants