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

dbref $id persisted as string instead of objectid #2

Closed
gwilym opened this issue Jul 15, 2010 · 8 comments
Closed

dbref $id persisted as string instead of objectid #2

gwilym opened this issue Jul 15, 2010 · 8 comments

Comments

@gwilym
Copy link

gwilym commented Jul 15, 2010

I've noticed this when playing around with the sandbox and references:

(output of mongo shell)

db.testcollection.findOne().references[0]
{ "$ref" : "testreference", "$id" : "4c3f0b456cc8849c17ab0000" }

The $id of the dbref here is a string, but I would expect it to be an ObejctId (a MongoId in PHP), like so:

db.testcollection.findOne().references[0]
{ "$ref" : "testreference", "$id" : ObjectId("4c3f0b456cc8849c17ab0000") }

This allows for...

db.testcollection.findOne().references[0].fetch()
{ ... referenced document here ... }

I couldn't find a note if this was intended by the odm or not, but an ObjectId is the proper format, here:

http://www.mongodb.org/display/DOCS/Database+References

@avalanche123
Copy link
Contributor

will look into it, thanks

@jwage
Copy link
Member

jwage commented Jul 30, 2010

Can you create the issue in jira?

http://www.doctrine-project.org/jira

@avalanche123
Copy link
Contributor

@hex337
Copy link

hex337 commented Aug 13, 2010

So I just pulled this, and now I have an issue.

In my query, I do this:
$this->createQuery('Message')->field('sender.$id')->equals($userId)

I get nothing as the response. I can't find anything in the query docs to see how to build my query to make this work.

@avalanche123
Copy link
Contributor

Try ...->equals(new \MongoId($userId));
Also please gist what you're doing so that we could see the exact code.

@hex337
Copy link

hex337 commented Aug 13, 2010

What does gist mean? Sorry, new to a lot of this.

@jwage
Copy link
Member

jwage commented Aug 13, 2010

This should be fixed. The $id is stored as a MongoId properly now.

@epicwhale
Copy link

Besides the identify field of the document, how do you store a MongoId in some other field? in cases where I'm manually referencing documents. I don't want to store them as strings. I've explained my issue here: http://stackoverflow.com/questions/6644033/how-do-you-store-an-objectid-while-using-doctrine-mongodb-odm

This issue was closed.
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

5 participants