Skip to content

v2 MaybeUndefined: tri-state patch fields and upsert payloads - #112

Merged
Rizzen merged 2 commits into
masterfrom
mark/updates-are-upserts-model
Aug 5, 2026
Merged

v2 MaybeUndefined: tri-state patch fields and upsert payloads#112
Rizzen merged 2 commits into
masterfrom
mark/updates-are-upserts-model

Conversation

@Rizzen

@Rizzen Rizzen commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@Rizzen
Rizzen requested a review from Ololoshechkin July 28, 2026 15:34
@Rizzen
Rizzen force-pushed the mark/updates-are-upserts-model branch from b7c8430 to 33ba03b Compare July 31, 2026 12:41
@Rizzen
Rizzen marked this pull request as ready for review July 31, 2026 12:41
@Rizzen
Rizzen requested a review from EugeneTheDev July 31, 2026 12:49

@EugeneTheDev EugeneTheDev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nit comments

* keeps [previous], [MaybeUndefined.Null] clears it, and [MaybeUndefined.Value] replaces it.
*/
@UnstableApi
public fun <T> MaybeUndefined<T>.update(previous: T?): T? = when (this) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function confused me for a bit, because it reads the other way. Since you read from left to right, it reads like "this MaybeUndefined is updated with previous value", but in reality it's the opposite. Wdyt swapping the sides of this function to make the intention clearer?

fun <T> T?.update(value: MaybeUndefined<T>): T? 

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then it migrates from the MaybeUndefined extensions to T? extension, I'm not sure we want to do that, it's hard to find

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. Wdyt keeping it as an extension on MaybeUndefined then, but renaming to something like takeOrPrevious, to align with standard Kotlin naming conventions?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, sorry, I missed that, similar to the orPrevious below, this one looks like getOrElse from Option monad too. I guess moving it to MaybeUndefined too and calling it getOrElse would align it with Option monad even better

@Rizzen
Rizzen merged commit 69eca3a into master Aug 5, 2026
1 check passed
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.

2 participants