LEFT_SUBFIELD only supports Object

Showing 1-7 of 7 messages
LEFT_SUBFIELD only supports Object Ryan Mahoney 3/28/12 10:30 AM
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
Re: [mongodb-user] LEFT_SUBFIELD only supports Object Aaron Westendorf 3/30/12 6:12 AM
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

> --
> 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 mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@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
aa...@agoragames.com
www.agoragames.com

Re: [mongodb-user] LEFT_SUBFIELD only supports Object Scott Hernandez 3/30/12 7:51 AM
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

Re: [mongodb-user] LEFT_SUBFIELD only supports Object Aaron Westendorf 3/30/12 8:24 AM
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.
Re: [mongodb-user] LEFT_SUBFIELD only supports Object Glenn Maynard 3/30/12 8:24 AM
On Fri, Mar 30, 2012 at 9:51 AM, Scott Hernandez <scotthe...@gmail.com> 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


Re: [mongodb-user] LEFT_SUBFIELD only supports Object Scott Hernandez 3/30/12 8:42 AM
On Fri, Mar 30, 2012 at 11:24 AM, Glenn Maynard <gl...@zewt.org> wrote:
> On Fri, Mar 30, 2012 at 9:51 AM, Scott Hernandez <scotthe...@gmail.com>
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.

Re: [mongodb-user] LEFT_SUBFIELD only supports Object Alex Zylman 6/26/13 2:23 PM
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"