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

SqlPreprocessor generates wrong query for UNION #248

Closed
KacerCZ opened this issue Jan 10, 2020 · 0 comments
Closed

SqlPreprocessor generates wrong query for UNION #248

KacerCZ opened this issue Jan 10, 2020 · 0 comments

Comments

@KacerCZ
Copy link

KacerCZ commented Jan 10, 2020

Version: 3.0.5

Bug Description

When running SQL query with UNION and with limit set on result of UNION, parameters are inserted directly into query and not passed via placeholders.

(select id from product where id<?) union (select id from product) limit ? offset ?

Steps To Reproduce

Run following code:

$database = $this->context->getByType(\Nette\Database\Connection::class);
$database->query('(select id from product where id<?) union (select id from product) limit ? offset ?', 3, 5, 2);

Generated query:

(select id from product where id<'3') union (select id from product) limit '5' offset '2'

Result is exception "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''5' offset '2'' at line 1".

Database is MariaDB, used driver class is MySqlDriver from nette/database.

Expected Behavior

Placeholders are used and query after preprocessing looks like this:

(select id from product where id<?) union (select id from product) limit ? offset ?
@dg dg closed this as completed in 7b34e6f Jan 10, 2020
dg added a commit that referenced this issue Jan 10, 2020
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