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

feat(sql): allow update queries with auto-joining via sub-queries #537

Merged
merged 1 commit into from May 2, 2020

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented May 2, 2020

qb.update({ name: 'test 123', type: PublisherType.GLOBAL }).where({ books: { author: 123 } });`

will result in following query:

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 B4nan mentioned this pull request May 2, 2020
46 tasks
```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 B4nan merged commit f3918a9 into dev May 2, 2020
@B4nan B4nan deleted the update-sub-query branch May 2, 2020 17:13
B4nan added a commit that referenced this pull request 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 pull request 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 pull request 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 pull request 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 pull request 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 pull request 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 pull request 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant