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

Already on GitHub? Sign in to your account

wrong hydration on right join #606

Closed
johnarevalo opened this Issue Feb 16, 2013 · 4 comments

Comments

Projects
None yet
2 participants

with these tables:

    <table name="product_type">
        <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
        <column name="name" type="varchar" required="true" primaryString="true"/>
        <column name="unit" type="varchar" required="true"/>
        <column name="logo" type="varchar"/>
        <behavior name="timestampable" />
    </table>

    <table name="product">
        <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
        <column name="last_price" type="double" required="true"/>
        <column name="station_id" type="integer" required="true" />
        <column name="type_id" type="integer" required="true" />
        <foreign-key foreignTable="product_type" phpName="Type">
            <reference local="type_id" foreign="id"/>
        </foreign-key>
        <behavior name="timestampable" />
    </table>

And this PropelCriteria

$products = ProductQuery::create()
        ->rightJoinWith('Type')
        ->addJoinCondition('Type', ProductPeer::STATION_ID . ' = ?', $station->getId())
        ->find();

generate this query

SELECT product.id, product.last_price, product.station_id, product.type_id, product.created_at, product.updated_at, product_type.id, product_type.name, product_type.unit, product_type.logo, product_type.created_at, product_type.updated_at 
FROM `product` 
RIGHT JOIN `product_type` ON (product.type_id=product_type.id AND product.station_id = 2)

Which it is just as I expected, I run this query directly in MySQL and works like a charm.
However, when Propel hydrates objects, only does it right for "Products" which are registered, remainder "ProductTypes" are cloned with the last row in the resultset.

I would like to know if this is the right way to build this query.

Regards,

Member

staabm commented Feb 16, 2013

could you provide a unit test?

@johnarevalo johnarevalo added a commit to johnarevalo/Propel that referenced this issue Feb 16, 2013

@johnarevalo johnarevalo Issue #606 supporting with test unit 53990e7

I've created a simple test class to confirm this issue.

Regards,

Member

staabm commented Feb 18, 2013

thanks,.. I will have a look at it on the weekend.

Member

staabm commented Feb 26, 2013

moved unit test into separte PR #619 ... discussion continues there.

@staabm staabm closed this Feb 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment