SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Implemented type-safe primary keys

Open egormanga opened this issue 2 months ago • 0 comments

Description of Changes

  • Note: based on (and includes) #2957.

For a table like this:

#[table]
struct User {
	#[primary_key]
	id: Identity
}

generates a type like that:

#[allow(dead_code)]
#[derive(SpacetimeType)]
struct UserId(Identity);

impl std::borrow::Borrow<Identity> for UserId {
	fn borrow(&self) -> &Identity {
		&self.0
	}
}

Yet to make it treat the type as Identity. Perhaps a trait is needed instead of a newtype.

  • Resolves #3472.

API and ABI breaking changes

TBD.

Expected complexity level and risk

TBD.

Testing

  • [x] Module compiles
  • [ ] Module publishes

egormanga avatar Oct 23 '25 23:10 egormanga