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

Invalid object ID #27

Closed
rapocalypse opened this issue Aug 26, 2013 · 5 comments
Closed

Invalid object ID #27

rapocalypse opened this issue Aug 26, 2013 · 5 comments

Comments

@rapocalypse
Copy link

Don't know if it's a real issue or a feature needed, but there's some way to not throw an exception when a search doesn't find a object with the specified _id ?

Perhaps act like the mysql, returning an empty value if there isn't a object with the selected _id…

I'm doing this: MongoModel::where('_id',$data['_id'])->first();

jenssegers added a commit that referenced this issue Aug 26, 2013
@jenssegers
Copy link
Contributor

I added some tests for this, but I don't see an exception? What exception did you get?

@rapocalypse
Copy link
Author

Hi,

I got an MongoException Invalid Object ID, on
/­vendor/­jenssegers/­mongodb/­src/­Jenssegers/­Mongodb/­Builder.php:521

The error happens when I do: MyMongoModel::where('_id',$someObjectID)->first();

I forced the error specifying a wrong Object ID, for example, the right Object ID is: 521b64a4fa4634aa068b456b and I pass 521b64a4fa4634aa068b45 (missing the last two characters).

I expected to get a NULL or empty response.

I'm using mongo v2.4.5 on a ubuntu 12.04 running with apache and php 5, on a Vagrant machine. Something due this config?

Thanks!

@jenssegers
Copy link
Contributor

Are you using the latest version of this library?

@rapocalypse
Copy link
Author

Yeap… just did a composer update right now to check and I'm with the last version.

@jenssegers
Copy link
Contributor

What is on line 512 in your version? Because I only have a closing bracket on that line.

mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this issue Sep 2, 2024
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