Native query exception while named parameter is null used in query #7508

Open
opened 2026-01-22 15:52:35 +01:00 by admin · 0 comments
Owner

Originally created by @saifulferoz on GitHub (May 26, 2025).

Bug Report

Q A
Version 5.4.45
Previous Version if the bug is a regression x.y.z

Summary

Current behavior

My native query is WITH due_base AS (select portfolio.student_id,
portfolio.full_name student_name,
portfolio.short_code as program,
sum(installment.net_payable - installment.net_receivable) as payable,
COALESCE(sum(adv_due.total_payable), 0) -COALESCE(sum(adv_due.total_receivable), 0) as total_payable
from fin_payment_requests payment_request
inner join fin_payment_installments installment
on payment_request.id = installment.request_id
and installment.payment_status = 'DUE'
inner join std_student_academic_portfolios portfolio
on payment_request.portfolio_id = portfolio.id
LEFT JOIN fin_prior_due_advance adv_due
ON adv_due.portfolio_id = portfolio.id
AND (adv_due.is_applied IS false
OR adv_due.is_removable IS true)
where payment_request.semester_session_id <= ?
and portfolio.current_session_semester_id = ?
and portfolio.academic_type in ('UNDERGRADUATE', 'POSTGRADUATE')
and payment_request.payment_status IN ('DUE', 'PARTIALLY_PAID')
and (? is null or portfolio.academic_type=?)
and (? is null or portfolio.short_code=?)
group by portfolio.student_id, portfolio.full_name, portfolio.short_code)
SELECT student_id,student_name, program,
payable + total_payable AS total_payable
FROM due_base
WHERE payable + total_payable > 0

Params: Array
(
[0] => 20251
[1] => 20251
[2] =>
[3] =>
[4] =>
[5] =>
)
and Types
Array
(
[0] => 2
[1] => 2
[2] => 0
[3] => 0
[4] => 0
[5] => 0
)

Getting exception An exception occurred while executing a query: SQLSTATE[42P18]: Indeterminate datatype: 7 ERROR: could not determine data type of parameter $3

Expected behavior

Application should execute the query and return result

How to reproduce

use named parameter and check named parameter is null or name parameter used in a column value check.

Originally created by @saifulferoz on GitHub (May 26, 2025). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |-------------------------------------------- | ------ | Version | 5.4.45 | Previous Version if the bug is a regression | x.y.z #### Summary <!-- Provide a summary describing the problem you are experiencing. --> #### Current behavior My native query is WITH due_base AS (select portfolio.student_id, portfolio.full_name student_name, portfolio.short_code as program, sum(installment.net_payable - installment.net_receivable) as payable, COALESCE(sum(adv_due.total_payable), 0) -COALESCE(sum(adv_due.total_receivable), 0) as total_payable from fin_payment_requests payment_request inner join fin_payment_installments installment on payment_request.id = installment.request_id and installment.payment_status = 'DUE' inner join std_student_academic_portfolios portfolio on payment_request.portfolio_id = portfolio.id LEFT JOIN fin_prior_due_advance adv_due ON adv_due.portfolio_id = portfolio.id AND (adv_due.is_applied IS false OR adv_due.is_removable IS true) where payment_request.semester_session_id <= ? and portfolio.current_session_semester_id = ? and portfolio.academic_type in ('UNDERGRADUATE', 'POSTGRADUATE') and payment_request.payment_status IN ('DUE', 'PARTIALLY_PAID') and (? is null or portfolio.academic_type=?) and (? is null or portfolio.short_code=?) group by portfolio.student_id, portfolio.full_name, portfolio.short_code) SELECT student_id,student_name, program, payable + total_payable AS total_payable FROM due_base WHERE payable + total_payable > 0 Params: Array ( [0] => 20251 [1] => 20251 [2] => [3] => [4] => [5] => ) and Types Array ( [0] => 2 [1] => 2 [2] => 0 [3] => 0 [4] => 0 [5] => 0 ) Getting exception An exception occurred while executing a query: SQLSTATE[42P18]: Indeterminate datatype: 7 ERROR: could not determine data type of parameter $3 #### Expected behavior Application should execute the query and return result #### How to reproduce use named parameter and check named parameter is null or name parameter used in a column value check.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7508