mistake in php driver

85 views
Skip to first unread message

Nours troisCentDouze

unread,
Dec 24, 2014, 9:01:08 AM12/24/14
to mongo...@googlegroups.com
Hy,

I found a mistake in mongo php driver :
we can save
$datas = ['key.forbidden' => "data"] ;
$collection->insert($datas) ;

  ... but ... we'll have problem to use it ...  no ?


How and where can I report that ?

mongo PECL driver 1.5.6

no php Exception, ...

When you want to manipulate datas with shell, you need to rename all fields

Eric Milkie

unread,
Dec 29, 2014, 10:04:27 AM12/29/14
to mongo...@googlegroups.com
Hello,
You can report PHP issues in our JIRA here:
-Eric

Jeremy Mikola

unread,
Dec 31, 2014, 11:35:37 AM12/31/14
to mongo...@googlegroups.com
I wasn't able to reproduce this on the version you cited. Consider the following PHP shell snippet:

>>> phpversion('mongo')
=> "1.5.6"
>>> $m = new MongoClient
=> <MongoClient #000000001f59941d00007f823d68cd67> {}
>>> $m->test->foo->insert(['key.forbidden' => "data"])
MongoException with message ''.' not allowed in key: key.forbidden'

For what it's worth, all versions of the driver going back to 1.0 (see this commit) have raised errors/exceptions if keys contained periods in documents destined for storage (e.g. not query criteria). Attempting to sidestep the driver's precautions by crafting an invalid field name in an update modifier will still trigger the server's validation:

>>> $m->test->foo->update(['x'=>1],['$set'=>['x'=>['y.z'=>1]]])
MongoWriteConcernException with message 'localhost:27017: The dotted field 'y.z' in 'x.y.z' is not valid for storage.'




--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev...@googlegroups.com.
To post to this group, send email to mongo...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-dev.
For more options, visit https://groups.google.com/d/optout.

philipseb...@gmail.com

unread,
Feb 24, 2015, 10:13:35 AM2/24/15
to mongo...@googlegroups.com
Is this issue is fixed in latest versions ?
If so could you please let me know the versions?

I am facing same issue when trying to insert document having dot in the  key.

Derick Rethans

unread,
Feb 27, 2015, 6:38:24 AM2/27/15
to mongo...@googlegroups.com
On Tue, 24 Feb 2015, philipseb...@gmail.com wrote:

> Is this issue is fixed in latest versions ?
> If so could you please let me know the versions?
>
> I am facing same issue when trying to insert document having dot in the
> key.

You're not supposed to be able to do that. MongoDB doesn't allow dots in
key names. The example that Jeremy showed below here, is how it should
behave.

cheers,
Derick


>
> On Wednesday, December 31, 2014 at 10:05:37 PM UTC+5:30, Jeremy Mikola
> wrote:
> >
> > I wasn't able to reproduce this on the version you cited. Consider the
> > following PHP shell snippet:
> >
> > >>> phpversion('mongo')
> > => "1.5.6"
> > >>> $m = new MongoClient
> > => <MongoClient #000000001f59941d00007f823d68cd67> {}
> > >>> $m->test->foo->insert(['key.forbidden' => "data"])
> > MongoException with message ''.' not allowed in key: key.forbidden'
> >
> > For what it's worth, all versions of the driver going back to 1.0 (see this
> > commit
> > <https://github.com/mongodb/mongo-php-driver/commit/0fe869685e1aa8c55f908a4ad0b57a1937abb30b>)
> > have raised errors/exceptions if keys contained periods in documents
> > destined for storage (e.g. not query criteria). Attempting to sidestep the
> > driver's precautions by crafting an invalid field name in an update
> > modifier will still trigger the server's validation:
> >
> > >>> $m->test->foo->update(['x'=>1],['$set'=>['x'=>['y.z'=>1]]])
> > MongoWriteConcernException with message 'localhost:27017: The dotted field
> > 'y.z' in 'x.y.z' is not valid for storage.'
> >
> >
> >
> >
> > On Wed, Dec 24, 2014 at 9:01 AM, Nours troisCentDouze <nour...@gmail.com
> > <javascript:>> wrote:
> >
> >> Hy,
> >>
> >> I found a mistake in mongo php driver :
> >> we can save
> >> $datas = ['key.forbidden' => "data"] ;
> >> $collection->insert($datas) ;
> >>
> >> ... but ... we'll have problem to use it ... no ?
> >>
> >>
> >> How and where can I report that ?
> >>
> >> mongo PECL driver 1.5.6
> >>
> >> no php Exception, ...
> >>
> >> When you want to manipulate datas with shell, you need to rename all
> >> fields
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "mongodb-dev" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an
> >> email to mongodb-dev...@googlegroups.com <javascript:>.
> >> To post to this group, send email to mongo...@googlegroups.com
> >> <javascript:>.
> >> Visit this group at http://groups.google.com/group/mongodb-dev.
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >
> >
>
>

--
{
website: [ "http://mongodb.org", "http://derickrethans.nl" ],
twitter: [ "@derickr", "@mongodb" ]
}
Reply all
Reply to author
Forward
0 new messages