mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #8425] Fetching entities with Composite Key Relations #10981
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?
Original Pull Request: https://github.com/doctrine/orm/pull/8425
State: closed
Merged: No
In our database design we are using entities with composite keys, and we are using composite keys relations between entities.
Let say we have the following entities with Primary Keys (PK):
Company(PK:company_code)Customer(PK composite:company_code+customer_code)Invoice(PK composite:company_code+invoice_code)and the following relations in
Invoice:Company(usingcompany_code), not nullableCustomer(using composite keycompany_code+customer_code), nullableNow we have
company_code(not null) but nocustomer_code(null).We want to fetch
Invoiceentity, so that we get not nullCompany, and nullCustomer.The problem is that loading
Invoicewith nullCustomeris not working - we are getting the following exception:This PR provide a fix, to load the
Customerin the described case.The change is pretty simply, and no other tests are affected.
NOTE: Loading
Companyis not a problem as it is using relation on just one column (not a composite key). The description includes it just for completeness of the example.