Ryan Mahoney | 28 Mar 19:30 2012
Picon

LEFT_SUBFIELD only supports Object

Hi All,

This message is for the benefit of anyone who sees this error in the future and to complain to the MongoDB devs  ;)

If you see this error:

LEFT_SUBFIELD only supports Object

Most likely, if you look at the document you are attempting to update (via $set), one of your keys is empty, for example:

{
    "_id" : ObjectId("4e52b5e08ead0e3853320000"),
    "title" : "Something",
    "url" : "http://www.website.org",
    "" : "",
    "tags" : [ "international"]
}

The only way I have corrected it is to update the entire document w/o the empty key remaining in the new replacement-document.

My question to the MongoDB devs is: why was this error even allowed to be inserted in the first place?  How does something like this even happen?

Thanks!

-r

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/BjEPUjlYBNUJ.
To post to this group, send email to mongodb-user-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
Aaron Westendorf | 30 Mar 15:12 2012

Re: LEFT_SUBFIELD only supports Object

We also ran into this problem in 2.0.2 just this week. We're trying to
optimize saving of large documents by writing only the changes, but
we've encountered numerous differences between "$set" and "store" that
are making the transition quite painful (dotted key notation,
RIGHT_SUBFIELD and LEFT_SUBFIELD errors).

I worked around this bug by first calling "$unset" with {"":1} but now
we have a guarantee of 2 operations per save, whereas $unset was
conditional in my first implementation.

-Aaron

On Wed, Mar 28, 2012 at 1:30 PM, Ryan Mahoney <virtuecenter@...> wrote:
> Hi All,
>
> This message is for the benefit of anyone who sees this error in the future
> and to complain to the MongoDB devs  ;)
>
> If you see this error:
>
> LEFT_SUBFIELD only supports Object
>
> Most likely, if you look at the document you are attempting to update (via
> $set), one of your keys is empty, for example:
>
> {
>     "_id" : ObjectId("4e52b5e08ead0e3853320000"),
>     "title" : "Something",
>     "url" : "http://www.website.org",
>     "" : "",
>     "tags" : [ "international"]
> }
>
> The only way I have corrected it is to update the entire document w/o the
> empty key remaining in the new replacement-document.
>
> My question to the MongoDB devs is: why was this error even allowed to be
> inserted in the first place?  How does something like this even happen?
>
> Thanks!
>
> -r
>
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mongodb-user/-/BjEPUjlYBNUJ.
> To post to this group, send email to mongodb-user@...
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@...
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.

-- 
Aaron Westendorf
Senior Software Engineer
Agora Games
359 Broadway
Troy, NY 12180
Phone: 518.268.1000
aaron@...
www.agoragames.com

--

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@...
To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Scott Hernandez | 30 Mar 16:51 2012
Picon

Re: LEFT_SUBFIELD only supports Object

There are many use-cases where "" can be used as a field name but
unfortunately update doesn't support this.

If you look at the bson spec you will see this is a valid field name.
http://bsonspec.org/#/specification

On Fri, Mar 30, 2012 at 9:12 AM, Aaron Westendorf <aaron@...> wrote:
> We also ran into this problem in 2.0.2 just this week. We're trying to
> optimize saving of large documents by writing only the changes, but
> we've encountered numerous differences between "$set" and "store" that
> are making the transition quite painful (dotted key notation,
> RIGHT_SUBFIELD and LEFT_SUBFIELD errors).
>
> I worked around this bug by first calling "$unset" with {"":1} but now
> we have a guarantee of 2 operations per save, whereas $unset was
> conditional in my first implementation.
>
> -Aaron
>
>
> On Wed, Mar 28, 2012 at 1:30 PM, Ryan Mahoney
<virtuecenter@...> wrote:
>> Hi All,
>>
>> This message is for the benefit of anyone who sees this error in the future
>> and to complain to the MongoDB devs  ;)
>>
>> If you see this error:
>>
>> LEFT_SUBFIELD only supports Object
>>
>> Most likely, if you look at the document you are attempting to update (via
>> $set), one of your keys is empty, for example:
>>
>> {
>>     "_id" : ObjectId("4e52b5e08ead0e3853320000"),
>>     "title" : "Something",
>>     "url" : "http://www.website.org",
>>     "" : "",
>>     "tags" : [ "international"]
>> }
>>
>> The only way I have corrected it is to update the entire document w/o the
>> empty key remaining in the new replacement-document.
>>
>> My question to the MongoDB devs is: why was this error even allowed to be
>> inserted in the first place?  How does something like this even happen?
>>
>> Thanks!
>>
>> -r
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "mongodb-user" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/mongodb-user/-/BjEPUjlYBNUJ.
>> To post to this group, send email to mongodb-user@...
>> To unsubscribe from this group, send email to
>> mongodb-user+unsubscribe@...
>> For more options, visit this group at
>> http://groups.google.com/group/mongodb-user?hl=en.
>
>
>
> --
> Aaron Westendorf
> Senior Software Engineer
> Agora Games
> 359 Broadway
> Troy, NY 12180
> Phone: 518.268.1000
> aaron@...
> www.agoragames.com
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@...
> To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>

--

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@...
To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Aaron Westendorf | 30 Mar 17:24 2012

Re: LEFT_SUBFIELD only supports Object

It's not that update doesn't support it, it's that update can't
operate on a record where the empty-string key already exists. I was
able to successfully clear the empty key with $unset.

On Fri, Mar 30, 2012 at 10:51 AM, Scott Hernandez
<scotthernandez@...> wrote:
> There are many use-cases where "" can be used as a field name but
> unfortunately update doesn't support this.
>
> If you look at the bson spec you will see this is a valid field name.
> http://bsonspec.org/#/specification
>
> On Fri, Mar 30, 2012 at 9:12 AM, Aaron Westendorf <aaron@...> wrote:
>> We also ran into this problem in 2.0.2 just this week. We're trying to
>> optimize saving of large documents by writing only the changes, but
>> we've encountered numerous differences between "$set" and "store" that
>> are making the transition quite painful (dotted key notation,
>> RIGHT_SUBFIELD and LEFT_SUBFIELD errors).
>>
>> I worked around this bug by first calling "$unset" with {"":1} but now
>> we have a guarantee of 2 operations per save, whereas $unset was
>> conditional in my first implementation.
>>
>> -Aaron
>>
>>
>> On Wed, Mar 28, 2012 at 1:30 PM, Ryan Mahoney
<virtuecenter@...> wrote:
>>> Hi All,
>>>
>>> This message is for the benefit of anyone who sees this error in the future
>>> and to complain to the MongoDB devs  ;)
>>>
>>> If you see this error:
>>>
>>> LEFT_SUBFIELD only supports Object
>>>
>>> Most likely, if you look at the document you are attempting to update (via
>>> $set), one of your keys is empty, for example:
>>>
>>> {
>>>     "_id" : ObjectId("4e52b5e08ead0e3853320000"),
>>>     "title" : "Something",
>>>     "url" : "http://www.website.org",
>>>     "" : "",
>>>     "tags" : [ "international"]
>>> }
>>>
>>> The only way I have corrected it is to update the entire document w/o the
>>> empty key remaining in the new replacement-document.
>>>
>>> My question to the MongoDB devs is: why was this error even allowed to be
>>> inserted in the first place?  How does something like this even happen?
>>>
>>> Thanks!
>>>
>>> -r
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "mongodb-user" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/mongodb-user/-/BjEPUjlYBNUJ.
>>> To post to this group, send email to mongodb-user@...
>>> To unsubscribe from this group, send email to
>>> mongodb-user+unsubscribe@...
>>> For more options, visit this group at
>>> http://groups.google.com/group/mongodb-user?hl=en.
>>
>>
>>
>> --
>> Aaron Westendorf
>> Senior Software Engineer
>> Agora Games
>> 359 Broadway
>> Troy, NY 12180
>> Phone: 518.268.1000
>> aaron@...
>> www.agoragames.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
>> To post to this group, send email to mongodb-user@...
>> To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongodb-user@...
> To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>

-- 
Aaron Westendorf
Senior Software Engineer
Agora Games
359 Broadway
Troy, NY 12180
Phone: 518.268.1000
aaron@...
www.agoragames.com

--

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@...
To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Glenn Maynard | 30 Mar 17:24 2012

Re: LEFT_SUBFIELD only supports Object

On Fri, Mar 30, 2012 at 9:51 AM, Scott Hernandez <scotthernandez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
There are many use-cases where "" can be used as a field name but
unfortunately update doesn't support this.

SERVER-2651/SERVER-5227 (fixed in 2.1)?
 
If you look at the bson spec you will see this is a valid field name.
http://bsonspec.org/#/specification

Well, not all BSON documents are actually legal to store (eg. "." in key names).

--
Glenn Maynard


--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to mongodb-user+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
Scott Hernandez | 30 Mar 17:42 2012
Picon

Re: LEFT_SUBFIELD only supports Object

On Fri, Mar 30, 2012 at 11:24 AM, Glenn Maynard <glenn@...> wrote:
> On Fri, Mar 30, 2012 at 9:51 AM, Scott Hernandez <scotthernandez@...>
> wrote:
>>
>> There are many use-cases where "" can be used as a field name but
>> unfortunately update doesn't support this.
>
>
> SERVER-2651/SERVER-5227 (fixed in 2.1)?

Yes, that is fixed in 2.1.0 so you won't get that error.

>> If you look at the bson spec you will see this is a valid field name.
>> http://bsonspec.org/#/specification
>
>
> Well, not all BSON documents are actually legal to store (eg. "." in key
> names).

Correct, and we try to keep that down to a minimum. The dot is really
a soft-limit as it just causes problems with queries/indexing. From
the server's point of view it doesn't really matter as long as you
don't reach into that field with some query/expression. We have found
it much easier for users/clients to simply not introduce this
confusion by disallowing it at that level.

> --
> Glenn Maynard
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To post to this group, send email to mongodb-user@...
> To unsubscribe from this group, send email to
> mongodb-user+unsubscribe@...
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.

Alex Zylman | 26 Jun 23:23 2013

Re: LEFT_SUBFIELD only supports Object

Sorry to revive something old, but I'm seeing a very similar issue in mongo 2.4.3.


I have a document that looks something similar to this, where a key whose name is a blank string is inside a nested document:

{
  "_id": <my id>,
  "data": {
    "": 1,
    "some_field": 2
  }
}

If I try to update "data.some_field" via $set I get "LEFT_SUBFIELD only supports Object: data. not: 2"

I can't do what someone else suggested of $unset because {$unset: {"data.": 1}} results in "Invalid mod field name, may not end in a period"

On Friday, March 30, 2012 8:42:05 AM UTC-7, Scott Hernandez wrote:
On Fri, Mar 30, 2012 at 11:24 AM, Glenn Maynard <gl... <at> zewt.org> wrote:
> On Fri, Mar 30, 2012 at 9:51 AM, Scott Hernandez <scotthe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>>
>> There are many use-cases where "" can be used as a field name but
>> unfortunately update doesn't support this.
>
>
> SERVER-2651/SERVER-5227 (fixed in 2.1)?

Yes, that is fixed in 2.1.0 so you won't get that error.

>> If you look at the bson spec you will see this is a valid field name.
>> http://bsonspec.org/#/specification
>
>
> Well, not all BSON documents are actually legal to store (eg. "." in key
> names).

Correct, and we try to keep that down to a minimum. The dot is really
a soft-limit as it just causes problems with queries/indexing. From
the server's point of view it doesn't really matter as long as you
don't reach into that field with some query/expression. We have found
it much easier for users/clients to simply not introduce this
confusion by disallowing it at that level.

> --
> Glenn Maynard
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To post to this group, send email to mongod...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> To unsubscribe from this group, send email to
> mongodb-user... <at> googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.

--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
mongodb-user+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
See also the IRC channel -- freenode.net#mongodb
 
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gmane