-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing #5887 - lazy loading of one-to-one relationship with custom id object #6274
Fixing #5887 - lazy loading of one-to-one relationship with custom id object #6274
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@necsord thanks for the PR but unfortunately it doesn't solve the issue.
Your test is only passing because you're setting the parameter type on the query (->setParameter('id', $customerId, Issue5887CustomIdObjectType::NAME)
).
* @Entity | ||
* @Table(name="issue5887_cart") | ||
*/ | ||
class Issue5887Cart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this class to the test file (like we have here).
|
||
namespace Doctrine\Tests\Models\Issue5887; | ||
|
||
class Issue5887CustomIdObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this class to the test file (like we have here).
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Types\Type; | ||
|
||
class Issue5887CustomIdObjectType extends Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this class to the test file (like we have here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can also inherit StringType
instead so you don't need to implement the method getSQLDeclaration()
.
* @Entity | ||
* @Table(name="issue5887_customer") | ||
*/ | ||
class Issue5887Customer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this class to the test file (like we have here).
@@ -16,7 +16,7 @@ static public function dataValidateModelSets() | |||
{ | |||
$modelSets = []; | |||
foreach (self::$_modelSets as $modelSet => $classes) { | |||
if ($modelSet == "customtype") { | |||
if (in_array($modelSet, ["customtype", "issue5887"])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed for inlined classes
@@ -302,6 +302,10 @@ | |||
Models\Issue5989\Issue5989Employee::class, | |||
Models\Issue5989\Issue5989Manager::class, | |||
], | |||
'issue5887' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed for inlined classes
@@ -576,6 +580,11 @@ protected function tearDown() | |||
$conn->executeUpdate('DELETE FROM issue5989_managers'); | |||
} | |||
|
|||
if (isset($this->_usedModelSets['issue5887'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed for inlined classes
@lcobucci Thanks for looking into this. I've applied changes regarding your comments and simplified test case to test only the most basic case I could come up with. The problem is not with the first query for
If you remove the applied change in |
Fixing case when lazy loading of entity in one-to-one relationship on the side without foreign key did not return eht entity because of custom type not being detected and properly formatted before applying to database query. Closes #5887
@necsord I've just rebased your branch to sync with Thanks for your contribution 😉 |
Fixing case when lazy loading of entity in one-to-one relationship on the side without foreign key
did not return the entity because of custom type not being detected and properly formatted before
applying to database query.