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

_id: null #51

Closed
kdauzickas opened this Issue Oct 31, 2012 · 10 comments

Comments

Projects
None yet
3 participants
@kdauzickas

kdauzickas commented Oct 31, 2012

Genghis fails to handle objects that have null for id, e.g. {_id: null}

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Oct 31, 2012

Owner

Hmm. That's interesting... Why do you have an object like that? :)

Owner

bobthecow commented Oct 31, 2012

Hmm. That's interesting... Why do you have an object like that? :)

@kdauzickas

This comment has been minimized.

Show comment
Hide comment
@kdauzickas

kdauzickas Oct 31, 2012

I created it accidentally. A bug nonetheless :)

kdauzickas commented Oct 31, 2012

I created it accidentally. A bug nonetheless :)

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Oct 31, 2012

Owner

Well, that was dumb. Thanks for reporting it. I'll try to figure out a way to save you from yourself ;)

Owner

bobthecow commented Oct 31, 2012

Well, that was dumb. Thanks for reporting it. I'll try to figure out a way to save you from yourself ;)

@kdauzickas

This comment has been minimized.

Show comment
Hide comment
@kdauzickas

kdauzickas Nov 1, 2012

php also spews out notices about array to string conversion when the id is an array (yup, an array). There is ambiguity in this case. Mongo documentation states: The _id value can be of any type with type ObjectId being the most common. It also states: The _id value may be of any type, other than arrays, so long as it is a unique. And the actual db ignores the last statement allowing to save objects with array ids.

kdauzickas commented Nov 1, 2012

php also spews out notices about array to string conversion when the id is an array (yup, an array). There is ambiguity in this case. Mongo documentation states: The _id value can be of any type with type ObjectId being the most common. It also states: The _id value may be of any type, other than arrays, so long as it is a unique. And the actual db ignores the last statement allowing to save objects with array ids.

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Nov 10, 2012

Owner

Two things on the array id:

  1. You're not using an array id. You're using a hash ID :)

  2. What you're seeing is a failure of the PHP Mongo driver. The "array" representation of a cursor — what you get when you do iterator_to_array — uses the document IDs as the array index. You can imagine how much that would mess things up if you tried to do something like this:

    $foo[array('some' => 'value')] = $document;
    

    It works most of the time because ObjectId instances __toString as a hex string of their ID. But you'll see the exact same error if you try to cast whatever your id value is into a string.

    I don't know if the bug has been reported yet, but you can check the 10gen JIRA tickets if you want. I'll try to find a workaround for Genghis, though, because unfortunately the PHP driver doesn't have the fastest bug fix turnaround at this point.

Owner

bobthecow commented Nov 10, 2012

Two things on the array id:

  1. You're not using an array id. You're using a hash ID :)

  2. What you're seeing is a failure of the PHP Mongo driver. The "array" representation of a cursor — what you get when you do iterator_to_array — uses the document IDs as the array index. You can imagine how much that would mess things up if you tried to do something like this:

    $foo[array('some' => 'value')] = $document;
    

    It works most of the time because ObjectId instances __toString as a hex string of their ID. But you'll see the exact same error if you try to cast whatever your id value is into a string.

    I don't know if the bug has been reported yet, but you can check the 10gen JIRA tickets if you want. I'll try to find a workaround for Genghis, though, because unfortunately the PHP driver doesn't have the fastest bug fix turnaround at this point.

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Nov 10, 2012

Owner

Here's where it all fails:

Owner

bobthecow commented Nov 10, 2012

Here's where it all fails:

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Nov 10, 2012

Owner

Okay. The null ID is fixed in de558c9 ... it'll go out in the next release :)

Owner

bobthecow commented Nov 10, 2012

Okay. The null ID is fixed in de558c9 ... it'll go out in the next release :)

@bobthecow bobthecow closed this Nov 10, 2012

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Nov 10, 2012

Owner

I fixed a couple more issues for when you use dumb IDs like null, these fixes will be in the next release as well :)

Owner

bobthecow commented Nov 10, 2012

I fixed a couple more issues for when you use dumb IDs like null, these fixes will be in the next release as well :)

@jmikola

This comment has been minimized.

Show comment
Hide comment
@jmikola

jmikola Nov 13, 2012

@bobthecow: Thanks for pinging me on this. I created PHP-570 to track the issue.

jmikola commented Nov 13, 2012

@bobthecow: Thanks for pinging me on this. I created PHP-570 to track the issue.

@bobthecow

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Nov 13, 2012

Owner

@jmikola Thanks for reporting it via the proper channel :)

Owner

bobthecow commented Nov 13, 2012

@jmikola Thanks for reporting it via the proper channel :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment