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

Question Mark in Field Alias Issue #6774

Open
sma27 opened this issue Feb 6, 2025 · 1 comment
Open

Question Mark in Field Alias Issue #6774

sma27 opened this issue Feb 6, 2025 · 1 comment

Comments

@sma27
Copy link

sma27 commented Feb 6, 2025

Bug Report

Q A
Version 4.2.2

pdo_mysql driver

Summary

Positional parameter at index 0 does not have a bound value error for question marks used within quotes.

Current behavior

MySQL query like the following:
SELECT my_question AS 'Why do you like turtles?'
FROM...

Causes an error: "Positional parameter at index 0 does not have a bound value." despite being enclosed in single quotes.

Modifying the query as follows:
SELECT my_question AS 'Why do you like turtles??'
FROM...

Returns two question marks in the result instead of one. As far as I can tell there is no way to use question marks in field aliases.

Expected behavior

I would expect the question mark to be treated as a literal within single quotes. Or, if that is not the case, I'd expect the escaped question mark to return a single question mark.

P.S. I am not using the query builder to perform this query. The code and query ran fine in Laminas DB. I am currently porting to Doctrine DBAL.

@sma27
Copy link
Author

sma27 commented Feb 7, 2025

It looks like the problem is actually the apostrophe mixed with a question mark.

SELECT my_question AS 'Why you''d like turtles?'
FROM...

Seems to work

But

SELECT my_question AS 'Why you\'d like turtles?'
FROM...

Causes an exception, shouldn't either work?

The problem seems to be caused with the combination of "\'" and "?" if I remove the question mark the problem also goes away. It must trip some strange case when parsed.

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

No branches or pull requests

1 participant