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

add QueryCreator.deleteFrom([t1, t2, ...]) overload. #269

Closed
igalklebanov opened this issue Jan 1, 2023 · 2 comments · Fixed by #299
Closed

add QueryCreator.deleteFrom([t1, t2, ...]) overload. #269

igalklebanov opened this issue Jan 1, 2023 · 2 comments · Fixed by #299
Assignees
Labels
api Related to library's API enhancement New feature or request greenlit Ready for implementation mysql Related to MySQL

Comments

@igalklebanov
Copy link
Member

igalklebanov commented Jan 1, 2023

Merge of #241 introduced deletes with joined tables for filtering in databases such as MySQL. This is a real tease for consumers using such a database, as it supports deleting from multiple tables in a single delete from query by simply listing multiple tables after from clause.

db.deleteFrom(['t1', 't2']).where(...).execute();

This is an addition of an overload of QueryCreator.deleteFrom with an array of table references as argument. It should behave similarly to the multi-table variant of QueryCreator.selectFrom.

@igalklebanov igalklebanov added enhancement New feature or request mysql Related to MySQL api Related to library's API labels Jan 1, 2023
@koskimas koskimas added the greenlit Ready for implementation label Jan 4, 2023
@igalklebanov
Copy link
Member Author

igalklebanov commented Jan 22, 2023

Hey @KostyaTretyak 👋

We love the excitement! but can you please open separate issues for each individual idea/problem/request?

By the way, for now deleteFrom with aliases works incorrectly:

await db
  .deleteFrom('t1' as any)
  .using('table1 as t1')
  .innerJoin('table2 as t2', ...)

As you can see, here is casting 't1' as any and it's not good.

Of course its not good.

  1. Casting as any breaks inference.
  2. as t1 is only added to the context in .using, don't expect it to magically be part of .deleteFrom's context. This is not how typescript works.

And It is also desirable that the following form of deletion is also supported:

delete t1
from table1 as t1
inner join table2 as t2
  on...

This has already been requested @ #237.

@igalklebanov
Copy link
Member Author

igalklebanov commented Jan 22, 2023

@KostyaTretyak not really.

This issue is a specific feature request.

Your comment talked about a bug with current API and then continued with a whole different feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request greenlit Ready for implementation mysql Related to MySQL
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants