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

Make ColumnIndexAttribute bitflags in the ABI #212

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Conversation

RReverser
Copy link
Member

@RReverser RReverser commented Aug 21, 2023

Description of Changes

(This is reopened #72 with some fixes.)

As we're adding more variants, it's getting harder to keep track of the "A implies B" relationships between enum variants and to correctly do checks like "is this column autoinc" in different places.

Using bitflags makes expressing those relationships more natural and checking simpler - e.g. you can just do contains(AUTO_INC) as a single bit operation instead of having to remember and list all possible variants that imply autoinc, especially if we're going to add more flags in the future.

Initially I was going to make this change just in C# module generator and convert between ABI enum and bitflags over there, but it seems better to do this at ABI level so it simplifies Rust handling as well.

API

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

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

As we're adding more variants, it's getting harder to keep track of the "A implies B" relationships between enum variants and to correctly do checks like "is this column autoinc" in different places.

Using bitflags makes expressing those relationships more natural and checking simpler - e.g. you can just do `contains(AUTO_INC)` as a single bit operation instead of having to remember and list all possible variants that imply autoinc, especially if we're going to add more flags in the future.

Initially I was going to make this change just in C# module generator and convert between ABI enum and bitflags over there, but it seems better to do this at ABI level so it simplifies Rust handling as well.
crates/lib/src/lib.rs Show resolved Hide resolved
crates/lib/src/lib.rs Show resolved Hide resolved
Copy link
Contributor

@kulakowski kulakowski left a comment

Choose a reason for hiding this comment

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

Approved but I don't know when a good time for an ABI breaking change is right now.

crates/lib/src/lib.rs Show resolved Hide resolved
@RReverser
Copy link
Member Author

We probably need to come up with some strategy to update C# dep when we change ABI. If this PR is merged now, that will make all the C# deps incompatible. The only way I can think of to avoid that would be to bump C# dep to 0.7.* and reference it in this same PR, so that both changes are merged at the same time. But that leaves spacetime-web which has its own project template that references 0.6.* C# deps...

I'm not sure what strategy is to update all of them together, in a way that ABI used by the website is compatible with that of the backend.

@mamcx mamcx merged commit cc632ef into master Aug 29, 2023
6 checks passed
@RReverser RReverser deleted the column-attr-bitflags branch September 2, 2023 11:32
RReverser added a commit that referenced this pull request Sep 12, 2023
This bumps C# dependency to be compatible with #212 when the next version of SpacetimeDB is released.
@RReverser RReverser mentioned this pull request Sep 12, 2023
4 tasks
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