-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Relational Ids stored as Strings #356
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
Comments
I think this is also the same problem the guy in issue #350 is seeing |
Possible workaround is to use the attribute mutator
or override the save method in hasone.php
or perhaps just override getParentKey
Anyone see any issues by doing that? |
I asked about this in #134 ... But I would still like to see this implemented some time, maybe as an option. One day when I have enough time, I'll try and see exactly what issues jens ran into, and find solutions .... |
My code above appears to take care of the insert but now I'm having issues with retrieving the objects with those modifications. So yeah, he pretty much sums it up in his comment. |
OK. With my changes I can do this and get the expected result:
This is a one-to-one relationship with the role_id being saved as an ObjectId rather than string Changes that had to be done HasOne.php:
BelongsTo.php:
I'm sure there are things I'm not considering.. Would like the author's feedback |
I agree that MongoId's are better, but it was too hard too implement it with the current way Eloquent is working. When Laravel 5 is released, and I can find some spare time, I will be looking into this. |
Is there any movement on this - I'm dealing with a legacy db which uses ObjectId throughout which I can't change. |
Would love to see this implemented too. I'm probably going to implement a workaround like the one listed above - not excited about it. |
I have been trying to do this for quite a while, but it takes a lot more changes than the one above. I'll have another go at it this weekend. |
+1 on having this implemented. Thanks |
1 similar comment
+1 on having this implemented. Thanks |
+1 |
+1 on having this implemented. Thanks |
+1 |
1 similar comment
+1 |
+1 would really love to see this implemented |
Wouldn't it be correct to store them as ObjectId?
I have a user object
My role object
When saved, a user document is created and has the correct role_id but the role_id type is String. The mongodb documentation says this should be an ObjectId
The text was updated successfully, but these errors were encountered: