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 using clause support @ DeleteQueryBuilder. #241

Merged
merged 25 commits into from
Jan 1, 2023

Conversation

igalklebanov
Copy link
Member

@igalklebanov igalklebanov commented Nov 26, 2022

Adding using to DeleteQueryBuilder:

  1. allows mysql consumers to use additional tables to filter what gets deleted from TDF* (it also allows using joins now, as they were not usable previously). Caveat in spec is you have to repeat yourself and add TDF* again in using clause in order to have additional tables (not in TDF*) as part of the query (via using or in joins) - delete from t1 using t1, t2 or delete from t1 using t1 inner join t2.

  2. allows postgres consumers to use additional tables to filter what gets deleted from TDF*.

* TDF = Table/s deleted from.

closes #177.

  • implement.
  • unit tests.
  • typings tests.
  • ts docs.

Takeaways:

  1. A follow-up PR needs to address DeleteQueryBuilder.returningAll(...). It should now allow passing a table argument (just like SelectQueryBuilder.selectAll(...)) so we could have t2.*.

  2. A follow-up PR should add QueryCreator.deleteFrom([t0, t1]) support. mysql supports deleting from multiple tables, and current PR is a real tease to our consumers since it allows to filter by additional tables but still delete only from one.

@igalklebanov igalklebanov added api Related to library's API enhancement New feature or request mysql Related to MySQL postgres Related to PostgreSQL labels Nov 26, 2022
@igalklebanov igalklebanov marked this pull request as ready for review December 10, 2022 14:10
@igalklebanov igalklebanov changed the title add using(...) @ DeleteQueryBuilder. add using clause support @ DeleteQueryBuilder. Dec 10, 2022
@igalklebanov
Copy link
Member Author

igalklebanov commented Dec 30, 2022

Reverted all the renames and type bloat in DeleteQueryBuilder. Thanks for feedback!

@koskimas
Copy link
Member

koskimas commented Jan 1, 2023

Awesome! 💯

@koskimas koskimas merged commit 5a6409b into kysely-org:master Jan 1, 2023
@igalklebanov igalklebanov deleted the delete-from-using branch January 1, 2023 22:15
@MoSheikh
Copy link
Contributor

MoSheikh commented Feb 6, 2023

Hi, thanks a lot for this functionality!

I was just using it and did notice however that table names provided in the "using" clause are not picked up by the CamelCasePlugin, leading to an error. Using snake case in the using clause does work, but ends up causing type errors since the table name is not recognized.

@MoSheikh
Copy link
Contributor

MoSheikh commented Feb 6, 2023

I created a PR to address the issue: feedback is appreciated!

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 mysql Related to MySQL postgres Related to PostgreSQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres deleteFrom(table) does not support using expression
4 participants