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
add querybuilder auto-join support for update
queries
#319
Labels
enhancement
New feature or request
Milestone
Comments
I will need to investigate a bit, the thing is that with update query you can't use aliases like this, also this is not natively supported in knex (which is used to create and run the query). But it could be possible to do this via subquery... |
B4nan
added a commit
that referenced
this issue
May 2, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
May 2, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
May 2, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
May 2, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
May 3, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
May 21, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
Jun 1, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
Jun 5, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
Jun 16, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
Aug 2, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
B4nan
added a commit
that referenced
this issue
Aug 9, 2020
```typescript qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });` ``` will result in following query: ```sql update `publisher2` set `name` = ?, `type` = ? 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 #319
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
The querybuilder auto-join support is really great! Trying to run as part of select works fine, i.e.
qb.select("*").where({activity: {enabled: true}})
select "e0".* from "tasks" as "e0" left join "activities" as "e1" on "e0"."activity_id" = "e1"."id" where "e1"."enabled" = $1
but changing to use
update
, i.e.qb.update({someField: someValue})
produces an error:
Describe the solution you'd like
The same auto-join support for update queries.
Describe alternatives you've considered
Going to try the hand-rolled joins next
The text was updated successfully, but these errors were encountered: