Update the exception thrown by findOneOrCreate() when used with a join. #287

Merged
merged 1 commit into from Feb 13, 2012

Conversation

Projects
None yet
2 participants
Member

fzaninotto commented Feb 13, 2012

When using a join() (or a useXXXQuery()) on a query, and then terminating with
findOneOrCreate(), Propel used to throw a non-explicit exception only in the case
where there was no result found:

PropelException: 'author.FIRST_NAME' could not be found in the field names
    of type 'colName'. These are: Array
...

The problem is that Propel cannot set the foreign key value, as the main
query uses a join and not a subquery. So Propel should indeed throw an
exception, but it should explain what to do more clearly:

PropelException: findOneOrCreate() cannot be used on a query with a join,
    because Propel cannot transform a SQL JOIN into a subquery.
    You should split the query in two queries to avoid joins.

This exception is now also thrown when the query has a result, to help spot
the problem during development (and not in production).

Fixes #261.

@fzaninotto fzaninotto Update the exception thrown by findOneOrCreate() when used with a join.
When using a join() (or a useXXXQuery()) on a query, and then terminating with
findOneOrCreate(), Propel used to throw a non-explicit exception only in the case
where there was no result found:

    PropelException: 'author.FIRST_NAME' could not be found in the field names
		of type 'colName'. These are: Array
    ...

The problem is that Propel cannot set the foreign key value, as the main
query uses a join and not a subquery. So Propel *should* indeed throw an
exception, but it should explain what to do more clearly:

    PropelException: findOneOrCreate() cannot be used on a query with a join,
		because Propel cannot transform a SQL JOIN into a subquery.
		You should split the query in two queries to avoid joins.

This exception is now also thrown when the query has a result, to help spot
the problem during development (and not in production).

Fixes #261.
891e332

willdurand merged commit 3d5dc3c into propelorm:master Feb 13, 2012

Owner

willdurand commented Feb 13, 2012

Thanks!

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