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

NFC: inline insert/delete update handling #86

Merged
merged 3 commits into from
May 14, 2024

Conversation

RReverser
Copy link
Member

@RReverser RReverser commented May 10, 2024

Description of Changes

Instead of a separate TableOp enum, and 4 fields to handle insert/delete metadata in DbOp, use a nullable struct that contains non-nullable object + bytes pair internally:

  • if insert is present (non-nullable) and delete is nullable, that naturally indicates insert operation
  • if insert is nullable and delete is not, that's a delete
  • if both are non-nullable, it's an update
  • if both are null, it's an internal "no change" state

This simplifies and shortens update handling as well as reduces risk of state getting out of sync - e.g. TableOp saying that the operation is insert should exist but field containing inserted value being null. Now nullable struct itself communicates whether there is an insert or not, without a separate enum.

API

  • This is an API breaking change to the SDK

If the API is breaking, please state below what will break

Requires SpacetimeDB PRs

List any PRs here that are required for this SDK change to work

@RReverser RReverser force-pushed the inline-insert-delete-handling branch 2 times, most recently from ea22959 to 867675c Compare May 10, 2024 23:23
@RReverser RReverser force-pushed the inline-insert-delete-handling branch from 9bbad08 to 2cea081 Compare May 13, 2024 15:50
Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

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

LGTM - seems like a generally good simplification 👍

@RReverser RReverser merged commit 3854c08 into master May 14, 2024
2 checks passed
@RReverser RReverser deleted the inline-insert-delete-handling branch May 14, 2024 11:48
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.

3 participants