mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Incorrect work with custom type in class table inheritance #6152
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 @voodoo-dn on GitHub (Jan 9, 2019).
Originally assigned to: @voodoo-dn on GitHub.
Bug Report
When I fetch order by ID, CardOrder must be returned. But in Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator::hydrateRowData in $sqlResult argument passed array with columns from WithdrawOrder(e.g. confirmation_status = null, confirmed_by = null), and Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator::hydrateRowData(row 130), throws exception, because my custom doctrine type not expects null value.
@Ocramius commented on GitHub (Jan 9, 2019):
What exception?
@voodoo-dn commented on GitHub (Jan 9, 2019):
\Doctrine\DBAL\Types\ConversionException
Because to table
payment_ordersjoinedpayment_card_ordersandpayment_withdraw_orders, columnsconfirmation_status,confirmed_bycontainsnullvalue. ConfirmationStatusType:: convertToPHPValue() do not expects null, it expects string(because ConfirmationStatus object is enum, which expectedpending,approved,declinedvalues).I MUST receive App\Domain\Payment\Model\CardOrder object from repository from tables
payment_orders+payment_card_orders.@Ocramius commented on GitHub (Jan 9, 2019):
I'd check first:
This would isolate the issue to either the persisters or the hydrators at first.
@voodoo-dn commented on GitHub (Jan 9, 2019):
SQL:
SELECT t0.id AS id_3, t0.operation AS operation_4, t0.status AS status_5, t0.description AS description_6, t0.created_at AS created_at_7, t0.updated_at AS updated_at_8, t0.client_ip AS client_ip_9, t0.client_user_agent AS client_user_agent_10, t0.user_id AS user_id_11, t0.payment_system_id AS payment_system_id_12, t0.type, t1.amount AS amount_13, t1.currency_id AS currency_id_14, t2.amount AS amount_15, t2.confirmation_status AS confirmation_status_16, t2.currency_id AS currency_id_17, t2.confirmed_by_id AS confirmed_by_id_18 FROM payment_orders t0 LEFT JOIN payment_card_orders t1 ON t0.id = t1.id LEFT JOIN payment_withdraw_orders t2 ON t0.id = t2.id WHERE t0.id = ?Result set(array dump to json):
@Ocramius commented on GitHub (Jan 9, 2019):
Hmm, so the
status_5is correctly set. Theconfirmation_status_16is correctlynulldue to JTI, and resultset rows are correctly transformed according to the corresponding DBAL type mappings.What can be done here is deferring DBAL type conversions until the column is effectively needed, instead of when the column is iterated upon on the row.
Would you be able to turn this into a minimal test case in https://github.com/doctrine/doctrine2/tree/master/tests/Doctrine/Tests/ORM/Functional/Ticket ?
@voodoo-dn commented on GitHub (Jan 9, 2019):
Thanks for the answer. I will try.
@voodoo-dn commented on GitHub (Jan 10, 2019):
How I can commit test? Or I need attach it to comment?
@Ocramius commented on GitHub (Jan 10, 2019):
Create a new branch from
2.6in this repository, then push it to your own fork and open a pull request. See https://help.github.com/articles/creating-a-pull-request/@voodoo-dn commented on GitHub (Jan 10, 2019):
@Ocramius, thanks. Test writed. https://github.com/doctrine/orm/pull/7566