Skip to content

FROM INNER JOIN bug #235

Description

@Arkemlar

In some cases new Propel version is generating wrong queries with omitted table name in FROM statement. Someone in stackoverflow said that in new propel version the right way to build queries is to use Queries, but as in main page mentioned, sfPropelORMPlugin fully supports BC. So I assume this as bug.
Example:

$c = new Criteria();
$c->setDistinct();

$c->addJoin(ShopProduct2shopRubricPeer::PRODUCT_ID, ShopProductPeer::ID);
$c->addJoin(ShopProduct2shopRubricPeer::RUBRIC_ID, ShopRubricPeer::ID);
$c3 = $c->getNewCriterion(ShopRubricPeer::ID, array(99), Criteria::IN);
$c4 = $c->getNewCriterion(ShopRubricPeer::PARENT_ID, array(99), Criteria::IN);
$c4->addOr($c3);
$c->addAnd($c4);

$c->add(ShopProductPeer::VISIBLE, 1);
$c->add(ShopProductPeer::WAREHOUSE, 0, Criteria::GREATER_THAN);
$c->addDescendingOrderByColumn('RAND()');
$c->setLimit($limit);
$items =  ShopProductPeer::doSelect($c);

Error text:
Unable to execute SELECT statement [SELECT DISTINCT shop_product.ID, shop_product.PARENT_ID, shop_product.RUBRIC_ID, <I excluded excess text>, shop_product.VISIBLE, FROM INNER JOINshop_productON (shop_product2shop_rubric.PRODUCT_ID=shop_product.ID) INNER JOINshop_rubricON (shop_product2shop_rubric.RUBRIC_ID=shop_rubric.ID) WHERE (shop_rubric.PARENT_ID IN (:p1) OR shop_rubric.ID IN (:p2)) AND shop_product.VISIBLE=:p3 AND shop_product.WAREHOUSE>:p4 ORDER BY RAND() DESC LIMIT 6] [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOINshop_productON (shop_product2shop_rubric.PRODUCT_ID=shop_product.I' at line 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions