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

FROM INNER JOIN bug #235

Open
Arkemlar opened this issue Nov 16, 2016 · 1 comment
Open

FROM INNER JOIN bug #235

Arkemlar opened this issue Nov 16, 2016 · 1 comment

Comments

@Arkemlar
Copy link

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]

@rozwell
Copy link
Contributor

rozwell commented Nov 16, 2016

That's a Propel, not the sfPropelORMPlugin bug.
But Propel should be BC too.

You excluded the excess text, so let me ask you about this part:
shop_product.VISIBLE, FROM INNER JOIN
Is the comma really between VISIBLE and FROM in generated query?

What's the schema for those tables, especially ShopProduct, to reproduce the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants