Skip to content
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

Avoid exception when no result #949

Merged
merged 1 commit into from Nov 20, 2019
Merged

Avoid exception when no result #949

merged 1 commit into from Nov 20, 2019

Conversation

VincentLanglet
Copy link
Member

Subject

I wrote a custom filter with Having/groupBy condition and got an exception when no result was found.

This was the query

SELECT count(DISTINCT a0_.id) AS sclr_0 FROM asv_contract a0_ LEFT JOIN asv_relaunch a1_ ON a0_.id = a1_.contract_id LEFT JOIN asv_client_role a2_ ON a0_.id = a2_.contract_id LEFT JOIN asv_external_client_id a3_ ON a2_.external_client_id = a3_.id LEFT JOIN asv_client a4_ ON a3_.client_id = a4_.id WHERE a4_.usagename LIKE ? GROUP BY a0_.id, a0_.admin_comment, a0_.external_contract_id, a0_.effective_date, a0_.end_date, a0_.updated_date, a0_.sent_to_partner_date, a0_.created_by_grc_date, a0_.completed_by_grc_date, a0_.pledge, a0_.management_mandate, a0_.contract_status, a0_.buy_worth, a0_.initial_amount, a0_.current_advances, a0_.is_investor_profile_ignored, a0_.investor_profile_ignored_date, a0_.is_complete, a0_.has_been_matched_with_created_contract, a0_.is_transferred, a0_.distribution_in_progress, a0_.cash_amount, a0_.initial_management_type, a0_.initial_management_profile, a0_.manual_input, a0_.bank_account_number, a0_.received_at, a0_.current_management_type, a0_.current_management_type_for_partner, a0_.current_management_profile, a0_.management_mode_change_date, a0_.business_identifier_code, a0_.origin, a0_.contract_type_id, a0_.initial_management_mode_id, a0_.bank_details_file_id, a0_.signed_subscription_document_file_id, a0_.webservice_response_id, a0_.mobile_invoice_file_id, a0_.proof_of_payment_origin_file_id, a0_.specific_terms_file_id HAVING COUNT(DISTINCT a1_.id) = ?

I think getOneOrNullResult' is safer than getSingleScalarResult`.
I am targeting this branch, because it's a bug fix.

Fixed

Do not return exception if Pager->computeNbResult has no result

@core23 core23 added the patch label Nov 20, 2019
@core23 core23 requested a review from a team November 20, 2019 18:17
@core23 core23 merged commit 23a2fda into sonata-project:3.x Nov 20, 2019
@VincentLanglet
Copy link
Member Author

Thanks for the quick merge @core23 @greg0ire

I don't like asking, but since I need this fix for work, is it possible to release it ?
Big thanks.

@VincentLanglet VincentLanglet deleted the patch-1 branch November 21, 2019 08:48
@greg0ire
Copy link
Contributor

I'm at the SfCon today, so it will be difficult for me to do that, but I will definitely be able to on Sunday. Feel free to beat me to it @soullivaneuh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants