mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
find() returns an entity of id 1 if a string is passed as $id and starts with 1 #6917
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kaamui on GitHub (Jan 27, 2022).
Bug Report
Summary
With just this in a table "Version" => {id:1, value:"1.6.2"} :
Current behavior
An entity of id
intval(<insert_what_you_want_here>)is returnedHow to reproduce
Create a simple entity as mentioned. Fill the table as mentioned. Try to dump find results to see how it behaves.
Expected behavior
IMHO, it should return null in the case the PK is of type INT and the user performs a search with a non-int value. I don't know if an explicit call to intval is performed, or if it happens more implicitly, but I think, for a PK of type int,
is_numeric($id)or something more robust could be performed to return null if not true. For "1.5.4", maybe it could throw an exception because not of the type of the PK, idk ...