Closed AndrewRademacher closed 1 year ago
Yeah, this makes sense. I can test whether there's a straight-forward fix.
What's the use case for a non-copy pkey though? In the wild, I've only seen integers and uuids.
In my case the key was just a String, that I use to store a Url.
I poked at this issue. I'm sure it's fixable, but it's apparently nontrivial because the macro has to behave differently depending on whether the type of the primary key field implements Copy
or not.
If this is an important bug, I can prioritize fixing it - but right now don't see a critical need.
I poked at this issue. I'm sure it's fixable, but it's apparently nontrivial because the macro has to behave differently depending on whether the type of the primary key field implements
Copy
or not.If this is an important bug, I can prioritize fixing it - but right now don't see a critical need.
We have a lot of composite keys, consisting of several strings or Vec<u8
> | [u8; 32]
I am running into this issue now - I generate nanoid keys on the server and want to use those as my IDs instead of Uuid or an autoincrementing integer.
Its not a deal breaker, I'll just create a new field on the struct for my nanoid but figured this is another datapoint for you to gauge priority.
+1. Tried to implement SessionStore
, but couldn't since by design the id is String
.
it's apparently nontrivial because the macro has to behave differently depending on whether the type of the primary key field implements Copy or not.
@kurtbuilds can you just assume that type implements Clone
? Every Copy
type implements Clone
, so that will expand the spectre of possible types while not decreasing performance (Clone
of Copy
types usually just uses copy
under the hood?). It shouldn't even be a breaking change.
Yeah that's a great point. Relaxing to Clone
does work here. PR welcome, otherwise I'll update this when I can get to this.
This should be fixed in 0.10.0
. Please let me know if you encounter any issues.
After modifying the test example to be:
I'm hunting for the issue, but I'm fairly new to defining macros.