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

Parameters used in LIMIT and OFFSET in MySQL get quoted and quoted wrong #6778

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

Comments

@sma27
Copy link

sma27 commented Feb 10, 2025

Bug Report

Q A
Version 4.2.2

pdo_mysql driver

Summary

Double quotes parameters in LIMIT and OFFSET

Current behavior

MySQL query like the following:
$query = "
SELECT *
FROM my_table
LIMIT :limit OFFSET :offset";

$qb->executeQuery($query, ['limit' => 10, 'offset' => 2]);

Throws an exception. It appears the SQL is being run as:

SELECT *
FROM my_table
LIMIT ''10'' OFFSET ''2''

My temporary fix was not to use parameters in the limit or offset, but shouldn't this be supported?

Expected behavior

The parameters passed in to the executeQuery functions are int parameters. I wouldn't expect them to be treated as strings.

SELECT *
FROM my_table
LIMIT 10 OFFSET 2

This is what I'd expect the SQL to be.

@sma27
Copy link
Author

sma27 commented Feb 10, 2025

It works if I pass in a types array, but it should be able to detect this in my opinion.

$qb->executeQuery($query, ['limit' => 10, 'offset' => 2], ['limit' => \Doctrine\DBAL\ParameterType::INTEGER, 'offset' => \Doctrine\DBAL\ParameterType::INTEGER]);

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