-
Notifications
You must be signed in to change notification settings - Fork 695
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 EntityClass#test(id) and support update { it[nullable] = nullable } #1277
Open
vlsi
wants to merge
7
commits into
JetBrains:main
Choose a base branch
from
vlsi:issues_1275_1276
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vlsi
commented
Jun 19, 2021
operator fun <S : Comparable<S>, ID : EntityID<S>, E : S?> set(column: Column<ID>, value: E) { | ||
operator fun <S : Comparable<S>> set(column: Column<out EntityID<S>?>, value: S?) { |
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 is the key signature change to support it[nullableIntRef] = null as Int?
. The rest (e.g. out
) is done to keep existing tests pass, and make code consistent.
vlsi
force-pushed
the
issues_1275_1276
branch
7 times, most recently
from
June 19, 2021 20:36
6dcfb99
to
f63b330
Compare
Key change is UpdateBuilder#setWithEntityIdValue, which now accepts column: Column<out EntityID<S>?>, value: S? previous signature was column: Column<out EntityID<S>>, value: S? A downside is that "[optionalReferenceColumn] = null" can't decide between "null as ColumnType?" and "null as EntityID<ColumnType>?" update { // it[optionalReferenceColumn] = null // <- does not work // Workaround: specify null type explicitly to call the proper overload it[optionalReferenceColumn] = null as EntityID<ColumnType>? // The following works as well: // it[optionalReferenceColumn] = null as ColumnType? } fixes JetBrains#1275
vlsi
force-pushed
the
issues_1275_1276
branch
3 times, most recently
from
June 19, 2021 21:35
1fb6ca7
to
be4042e
Compare
* Exception message would include the relevant table and column name * LiteralOp(...) and QueryParameter(...) would fail if user creates NULL value for non-nullable type * Single-value QueryBuilder#registerArgument is slightly faster as it no longer creates list fixes JetBrains#1268
vlsi
force-pushed
the
issues_1275_1276
branch
2 times, most recently
from
June 19, 2021 23:13
8f90538
to
858c54b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry for 7 commits in a single PR, however, I expect they could just land to the main branch as is, and creating 7 different PR and rebasing them 6 times (after each gets merged) would be unnecessary overhead (for both of you and me).
Notes:
I adjusted generics in
UpdateBuilder
, so there's one type parameter and others are moved to function arguments. That makes exceptions slightly easier to read and understand.I would like to reorder
set
functions inUpdateBuilder
: first put 2 setters for regular column type, then 2 setters for EntityID column. However, I did not do that because it would make review/comparison harder. I can do that in a separate commit if you like.it[nullableRef] = null
does not compile now. I have no idea how to solve it as it can't decide betweennull as Int?
andnull as EntityID<Int>?
. The workaround is to usenull as EntityID<Int>?
. It might make sense to addUpdateBuilder#setNull(Column)
API so users could write:Fixes #1275, #1276, #1268