-
Notifications
You must be signed in to change notification settings - Fork 278
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 MERGE
query support.
#700
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you, been waiting for this for a long time. |
Let's |
and...... it is rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dude, you are so good! This is perfect! Only one nitpick about maybe improving typescript perf. Feel free to ignore if it causes some typescript issues and doesn't improve perf. (you can just run time npm run test:typings
and see if anything changes).
Feel free to merge as soon as you like ❤️ ❤️
* delete | ||
* ``` | ||
*/ | ||
whenMatchedAnd<RE extends ReferenceExpression<DB, TT | ST>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it did great things to typescript performance to hoist all complex argument types (that would create a lot of new type instantiations) to generics. My theory (pulled straight from my butt) is that typescript doesn't instantiate and compare the argument types when they are generics when comparing the parent interface.
So here you'd use:
whenMatchedAnd<
RE extends ReferenceExpression<DB, TT | ST>,
VE extends OperandValueExpressionOrList<DB, TT | ST, RE>
>(
lhs: RE,
op: ComparisonOperatorExpression,
rhs: VE
): MatchedThenableMergeQueryBuilder<DB, TT, ST, TT | ST, O>
All where
and other methods of this family now use this style, so maybe you could switch to that here even if there's no performance benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user time went down by 1 sec. 👌
rhs: OperandValueExpressionOrList<DB, TT | ST, RE> | ||
): MatchedThenableMergeQueryBuilder<DB, TT, ST, TT | ST, O> | ||
|
||
whenMatchedAnd( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
whenMatchedAnd<E extends ExpressionOrFactory<DB, TT | ST, SqlBool>>(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one had barely any effect.
* This method is similar to {@link SelectQueryBuilder.whereRef}, so see the documentation | ||
* for that method for more examples. | ||
*/ | ||
whenMatchedAndRef( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaaand here.. Well you get the gist.
whenMatchedAndRef<
LRE extends ReferenceExpression<DB, TB>,
RRE extends ReferenceExpression<DB, TB>
>(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this had any effect.
closes #203.
This PR adds
MERGE
query support. A special, complex query supported by engines such as PostgreSQL, MS SQL Server and OracleDB. It combines boolean logic (ExpressionBuilder
shines here) between 2 tables (target table and source table) as a decision whether to insert, update or delete rows in a target table. There's a combination of various things that already exist in Kysely: filter expressions,ExpressionBuilder
,InsertQueryBuilder
andUpdateQueryBuilder
.Breaking changes:
into
is now optional inInsertQueryNode
as insert queries inthen
do not reference the table being inserted into. (then insert [(...columns...)] values ...
)table
is now optional inUpdateQueryNode
as update queries inthen
do not reference the table being updated. (then update set ...
)Things to add later:
top
clause support, we need it here too (for mssql).output
clause support, we need it here too (for mssql).insert default values
support, we need it here too (for postgres).only
and*
support, we need it here too (for postgres).progress: