Skip to content

Unable to use the question mark (?) character inside a string. #2573

@8483

Description

@8483

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, "?"]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions