Skip to content

Added Unit Test that checks the BTreeIndexBase Column implements IComparable #277

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rekhoff
Copy link
Contributor

@rekhoff rekhoff commented Mar 21, 2025

Adds a test to com.clockworklabs.spacetimedbsdk that checks if the BTreeIndexBase class Column implements the IComparable interface. This is the implementation side of issue clockworklabs/SpacetimeDB#2362.

API

  • This is an API breaking change to the SDK

Requires SpacetimeDB PRs

No specific PR are required for this change.

Testsuite

SpacetimeDB branch name: master

Testing

  • Ran dotnet test, all checks pass.

@rekhoff rekhoff requested a review from kazimuth March 24, 2025 15:21
Copy link
Contributor

@kazimuth kazimuth left a comment

Choose a reason for hiding this comment

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

Tests make sense, interesting use of reflection. Have one request.

Comment on lines +88 to +105
public sealed class UserHandle : RemoteTableHandle<EventContext, User>
{
protected override string RemoteTableName => "user";

public sealed class IdentityIndex : BTreeIndexBase<SpacetimeDB.Identity>
{
protected override SpacetimeDB.Identity GetKey(User row) => row.Identity;

public IdentityIndex(UserHandle table) : base(table) { }
}

public readonly IdentityIndex Identity;

internal UserHandle(DbConnection conn) : base(conn)
{
Identity = new(this);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This code won't catch problems that occur if the code generation changes in the future. To catch such problems, we'd need to write the same test against generated code. For example, we could add an index to the Message.Sender field in quickstart-chat -- these tests have access to the quickstart-chat generated code.

If you want to do that, it would be great; if not, I'm willing to merge this, but would appreciate a comment saying why this class is here. // Copy of generated code for a BTreeIndex; TODO: update if that code changes is messy but at least documents what is going on.

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