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

Identity and ConnectionId should implement IComparable #2348

Closed
rekhoff opened this issue Mar 5, 2025 · 2 comments
Closed

Identity and ConnectionId should implement IComparable #2348

rekhoff opened this issue Mar 5, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@rekhoff
Copy link
Contributor

rekhoff commented Mar 5, 2025

Issue:

When attempting to create a table that uses Identity as an index of a BTree like:

#[index(btree)]
pub identity: Identity,

Generated code in C# will throw the error:
The type 'SpacetimeDB.Identity' must be convertible to 'System.IComparable<SpacetimeDB.Identity>' in order to use it as parameter 'Column' in the generic class 'SpacetimeDB.RemoteTableHandle<EventContext,Row>.BTreeIndexBase<Column>'

This is because SpacetimeDB.Identity does not implement the IComparable interface:

public readonly record struct Identity

While we are at it, it makes sense to implement IComparable for ConnectionId as well:

public readonly record struct ConnectionId

@joshua-spacetime joshua-spacetime added the bug Something isn't working label Mar 5, 2025
@joshua-spacetime
Copy link
Collaborator

Note, unique constraints (which should be generating the same btree index) work just fine

#[unique]
pub identity: Identity,

@rekhoff
Copy link
Contributor Author

rekhoff commented Mar 7, 2025

Resolved by PR #2354

@rekhoff rekhoff closed this as completed Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants