-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
No clear way to get primary key in storage provider #1905
Comments
@tsibelman This might be a more complete way to extract the key from the public API. At least Also a thing here is that |
@veikkoeeva Why in your solution if primaryKey returned from grainReference.GetPrimaryKeyString() is not null you disregard the fact that it can contain long or guid part ? Internally grainreference have IsLong property exposing it will help somewhat but it will not solve all the issues. |
Isn't it exclusively either Reading the documentation it looks like the intended, public usage has been within the grain where one already knows the key. |
Key can be string, long, Guid, or one of the compound keys log and string, guid and string. So GetPrimaryKeyString will return you string for 2 different types of keys. |
What two different types of key My logic is (I phrased poorly the previous passage) that strings IDs don't have an extension key. Then the order I check for the keys in that specific order is for the exact reason Maybe in other words, I'm afraid you lost me, but I take another look later. :) |
You have two keys: In my testing calling GetPrimaryKeyString will return you not null for both of these types. So you can't be sure if it one or the other key by just checking for null. I working with latest release but maybe it changed in the code after that |
Here implementation of GetPrimaryKeyString from orleans\src\orleans\ids\grainid.cs |
this is a duplicate of #1068. |
@sergeybykov Do you have any thoughts about this issue ? |
@tsibelman As @shayhatsor mentioned in #1068, it looks like it would take a breaking change to solve this cleanly. I think it's a candidate for v2.0 where we'll likely have to make other major changes for .NET Core compatibility. |
Closing as a duplicate of #1068. |
Hi I have a custom storage provider and was trying to get the primary key from GrainReference that will work for all cases, this is a best solution that I was able to come to.
Why such a weird solution ? You may ask, I explain:
GrainReference has several methods that expose the information about primary key.
GetPrimaryKeyString
GetPrimaryKey
GetPrimaryKeyLong
GetPrimaryKeyString is internally calling overload of GetPrimaryKeyLong that has string output parameter. Because of this it will return string for grains with long compound keys and for grains that have only string key, so it not that useful and actually misleading. So I use GetPrimaryKeyLong by myself I saw that for grains with string keys GetPrimaryKeyLong will return zero as return param, so it actually not possible to distinguish between compound key that have long part set to zero and string key, I guess that is not that common for users to use zero for their key, but it still a bug.
In addition there no way other that getting an exception to check if primary key is long or guid.
I don't understand why GrainReference do not store the a type for it key, it would solve all of this weir mess.
The text was updated successfully, but these errors were encountered: