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

Cannot work with primary keys other than ObjectId #26

Open
sven5 opened this issue Nov 28, 2023 · 4 comments
Open

Cannot work with primary keys other than ObjectId #26

sven5 opened this issue Nov 28, 2023 · 4 comments

Comments

@sven5
Copy link

sven5 commented Nov 28, 2023

I'm facing an issue when the primary key is other than ObjectId.
We're using Guid strings as Id field.

When using ReplaceOneAsync I'm getting the error message
"'760a812e-7bd1-42f2-9892-75486e809655' is not a valid 24 digit hex string."

it's working correctly with the plain Mongo C# driver.

@johnknoop
Copy link
Owner

Hi @sven5

This is true, and unfortunately this would require a bit of a redesign of the API, since all methods that target a document by id only accept strings as ids:

image

I suppose this could be rewritten, but it won't happen in the next couple of days.

@sven5
Copy link
Author

sven5 commented Nov 29, 2023

Thanks for you reply. I fully understand this is a huge change.
However, the string id shouldn't be an issue as I'm using a Guid converted to a string in my documents.
example:

{
	"_id":"743707fc-467f-494f-bcb8-b7dc251e6179",
	"name":"John Doe"
}

@johnknoop
Copy link
Owner

Oh, I see. Then I suspect it's the StringObjectIdConvention that might be the problem. I think there's an argument for why that shouldn't even be a part of this library in the first place. I might be able to remove it.

@sven5
Copy link
Author

sven5 commented Nov 29, 2023

Yes, I think so. Perhaps you could look into it.
Thanks

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

No branches or pull requests

2 participants