DDC-3732: Entity with string @id can't be fetches #4580

Closed
opened 2026-01-22 14:45:24 +01:00 by admin · 6 comments
Owner

Originally created by @doctrinebot on GitHub (May 10, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user peter.zwegat:

I defined an entity id field with the annotation:

@ORM\Id
@ORM\Column(type="string", length=2)

It's not possible to fetch the entity neither with ->find() nor manually with a query builder (quoted etc., tried everything).

$qb->where('l.id = ?1');
$qb->setParameters([
1 => $this->getEntityManager()->getConnection()->quote($id)
]);

This return just null even if the entity with the given id exists.

When I not quote the passed id value it, I become this error:

Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 121 near 'fi': Error: 'fi' is not defined. (/..../vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php: 63)

'fi' ist just the country identifier here that is the entity id.

Originally created by @doctrinebot on GitHub (May 10, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user peter.zwegat: I defined an entity id field with the annotation: ``` @ORM\Id @ORM\Column(type="string", length=2) ``` It's not possible to fetch the entity neither with `->find()` nor manually with a query builder (quoted etc., tried everything). ``` $qb->where('l.id = ?1'); $qb->setParameters([ 1 => $this->getEntityManager()->getConnection()->quote($id) ]); ``` This return just null even if the entity with the given id exists. When I not quote the passed id value it, I become this error: ``` Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 121 near 'fi': Error: 'fi' is not defined. (/..../vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php: 63) ``` `'fi'` ist just the country identifier here that is the entity id.
admin added the Bug label 2026-01-22 14:45:24 +01:00
admin closed this issue 2026-01-22 14:45:25 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 10, 2015):

Comment created by @ocramius:

Quoting parameters explicit is not necessary.

Also, quoting parameters is not needed in DQL, as DQL is translated by looking at mappings anyway.

@doctrinebot commented on GitHub (May 10, 2015): Comment created by @ocramius: Quoting parameters explicit is not necessary. Also, quoting parameters is not needed in DQL, as DQL is translated by looking at mappings anyway.
Author
Owner

@doctrinebot commented on GitHub (May 10, 2015):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (May 10, 2015): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (May 10, 2015):

Comment created by peter.zwegat:

Yeah I only quoted the id for test purposes.
I go a step back:
->find('de') throws the exception that I posted in the issue.

String Id's are possible normally not?

@doctrinebot commented on GitHub (May 10, 2015): Comment created by peter.zwegat: Yeah I only quoted the id for test purposes. I go a step back: `->find('de')` throws the exception that I posted in the issue. String Id's are possible normally not?
Author
Owner

@doctrinebot commented on GitHub (May 10, 2015):

Comment created by @ocramius:

[~peter.zwegat] yes, it is allowed, but what exception are you getting?

@doctrinebot commented on GitHub (May 10, 2015): Comment created by @ocramius: [~peter.zwegat] yes, it is allowed, but what exception are you getting?
Author
Owner

@doctrinebot commented on GitHub (May 11, 2015):

Comment created by peter.zwegat:

This one when I try to find an entity by it's id:

Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 121 near 'fi': Error: 'fi' is not defined. (/..../vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php: 63)

'fi' is here the key. Just used the ->find method.

@doctrinebot commented on GitHub (May 11, 2015): Comment created by peter.zwegat: This one when I try to find an entity by it's id: `Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 121 near 'fi': Error: 'fi' is not defined. (/..../vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php: 63)` 'fi' is here the key. Just used the `->find` method.
Author
Owner

@doctrinebot commented on GitHub (May 11, 2015):

Comment created by @ocramius:

Please show some actual code in a gist - I'm doing guesswork here :-P

@doctrinebot commented on GitHub (May 11, 2015): Comment created by @ocramius: Please show some actual code in a gist - I'm doing guesswork here :-P
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4580