It gets treated as a variable placeholder and the ? is replaced with a passed in value.
select concat(dt.url, '/', d.posId, '?posTransactionId=', d.id) url
The ? should have some escape mechanism like \? or something.
How can this be achieved?
EDIT:
Made it work like this, by passing the ? as a parameter, which doesn't feel good.
let sql = `
set @tenantId = ?;
set @questionMarkCharacter = ?;
select
tenantId,
d.id,
concat(dt.name, ' - ', d.uid) name,
concat(dt.url, '/', d.posId, @questionMarkCharacter, 'posTransactionId=', d.id) url
from retail_posTransaction d
left join system_documentType dt on dt.id = d.documentTypeId
where tenantId = @tenantId
;
`
let result = await pool.query(query, [tenantId, "?"]);