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

[DoctrineParamConverter] The identifier id is missing for a query #204

Open
vjnrv opened this Issue Feb 24, 2013 · 4 comments

Comments

Projects
None yet
6 participants
Contributor

vjnrv commented Feb 24, 2013

This problem appeared after upgrading to 2.1.8.
I'm using Doctrine ORM 2.3.2.

I think this is related to an optional parameter in my controller action.

A workaround I use is to set the controller default value to null and the route default value to false (was null in 2.0.*).

Contributor

ruudk commented May 31, 2013

I'm having the same issue, setting it to false did the trick.

I'm having the same problem, but I didnt get solution , can anyone please help me

It seems that you use "id" parameter in your route like that
@route("/foo/{id}")
public function fooAction(FooClass $fooEntity, BarClass $barEntity = false)
{
}

where $fooEntity and $barEntity are doctrine entities.
if you use SensioFrameworkExtraBundle, than this is the same that

@route("/foo/{id}")
@paramconverter("fooEntity", class="AcmeBundle:FooClass")
@paramconverter("barEntity", class="AcmeBundle:BarClass")
public function fooAction(FooClass $fooEntity, BarClass $barEntity = false)
{
}

DoctrineParameterConverter try to find fooEntity with "id" and barEntity with "id" too!!
ParameterConverter tries to use route parameter as key value by default, so you should use option mapper with custom route parameter. After this conversation we get annotation that work correctly (according to the first code block)

@route("/foo/{foo_id}")
@paramconverter("fooEntity", class="AcmeBundle:FooClass", options={ "id" = "foo_id" })
public function fooAction(FooClass $fooEntity, BarClass $barEntity = false)
{
}

or

@route("/foo/{id}")
@paramconverter("fooEntity", class="AcmeBundle:FooClass")
@paramconverter("barEntity", class="AcmeBundle:BarClass", options={ "exclude": { "id" } })
public function fooAction(FooClass $fooEntity, BarClass $barEntity = false)
{
}

sensio/framework-extra-bundle version is 2.3

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