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

connection.execute does not handle ? for arrays correctly #1021

Closed
alexojegu opened this issue Nov 2, 2020 · 1 comment
Closed

connection.execute does not handle ? for arrays correctly #1021

alexojegu opened this issue Nov 2, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@alexojegu
Copy link
Contributor

alexojegu commented Nov 2, 2020

Describe the bug

The next:

const artists = [30, 29, 28, 27, 26];
const limit = 4;
const results = await this.connection.execute(
    `select e0.id, e1.* from artist as e0 left join lateral (
        select e2.* from tattoo as e2 where e2.artist_id = e0.id order by e2.id desc limit ?
    ) as e1 on e0.id = e1.artist_id where e1.artist_id in (?)`,
    [limit, artists],
);

Create the following query:

select e0.id, e1.* from artist as e0 left join lateral ( select e2.* from tattoo as e2 where e2.artist_id = e0.id order by e2.id desc limit 4 ) as e1 on e0.id = e1.artist_id where e1.artist_id in ('[30,29,28,27,26]')

Notice the quotes in the last clause where e1.artist_id in ('[30,29,28,27,26]')

Expected behavior
Should not embrace array into quotes.

Additional context
I'm not sure which version it changed the behavior.

This work correctly:

const artists = [30, 29, 28, 27, 26];
const limit = 4;
const results = await this.connection.execute(
    `select e0.id, e1.* from artist as e0 left join lateral (
        select e2.* from tattoo as e2 where e2.artist_id = e0.id order by e2.id desc limit ?
    ) as e1 on e0.id = e1.artist_id where e1.artist_id in (${artists})`,
    [limit],
);
select e0.id, e1.* from artist as e0 left join lateral ( select e2.* from tattoo as e2 where e2.artist_id = e0.id order by e2.id desc limit 4 ) as e1 on e0.id = e1.artist_id where e1.artist_id in (30,29,28,27,26)

Versions

Dependency Version
node 14.14.0
typescript 4.0.3
mikro-orm 4.2.3
your-driver mysql
@B4nan B4nan added the bug Something isn't working label Nov 4, 2020
@B4nan B4nan closed this as completed in a21735f Nov 4, 2020
@B4nan
Copy link
Member

B4nan commented Nov 4, 2020

Available for testing as 4.2.4-dev.97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants