Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

wrong hydration on right join #606

Closed
johnarevalo opened this Issue · 4 comments

2 participants

@johnarevalo

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,

@staabm
Collaborator

could you provide a unit test?

@johnarevalo johnarevalo referenced this issue from a commit in johnarevalo/Propel
@johnarevalo johnarevalo Issue #606 supporting with test unit 53990e7
@johnarevalo

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

Regards,

@staabm
Collaborator

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

@staabm staabm referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@staabm
Collaborator

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

@staabm staabm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.