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
Nested query conditions in repository.remove cause TypeError #492
Comments
This was never meant for update or delete queries. Will see if I can make this work in v4, if nothing better, we could at least do 2 queries under the hood (select PK and delete by PK). As a workaround, select the entity as usual and remove the reference you get. |
Thanks for your reply, I thought MikroORM is supporting this already and I just found a bug. So in this case, consider this more as a feature request than a bug 😄 |
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
```typescript qb.delete({ books: { author: 123 } });` ``` will result in following query: ```sql delete from `publisher2` where `id` in (select `e0`.`id` from ( select distinct `e0`.`id` from `publisher2` as `e0` left join `book2` as `e1` on `e0`.`id` = `e1`.`publisher_id` where `e1`.`author_id` = ? ) as `e0`) ``` Closes #492
Describe the bug
When calling the
.remove(...)
method of a repository with nested query conditions, it causes a TypeError.Stack trace
To Reproduce
I've created a sample repository to reproduce this issue, use
ts-node src/main.ts
to run.https://github.com/jasperroloff/mikro-orm-nested-query-delete-issue
Expected behavior
It should successfully delete the entity, since a findOne given the same query does succeed.
Additional context
I've experienced this issue with (at least) the mariadb driver and the ReflectMetadataProvider.
Versions
(see package.json in sample repo)
The text was updated successfully, but these errors were encountered: