[SERVER-2441] ensureIndex records arbitrary direction objects Created: 31/Jan/11  Updated: 22/Feb/12  Resolved: 31/Jan/11

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Trivial - P5
Reporter: Scott Hernandez (Inactive) Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-1627 add createIndexes command Closed
Operating System: ALL
Participants:

 Description   

> db.test5.ensureIndex(

{x:"foo"}

)
> db.test5.getIndexes()
[
{
"name" : "id",
"ns" : "test.test5",
"key" :

{ "_id" : 1 }

},
{
"_id" : ObjectId("4d46194d53ffe3441923319f"),
"ns" : "test.test5",
"key" :

{ "x" : "foo" }

,
"name" : "x_",
"v" : 0
}
]

It seems like it should be 1 of the 3 possible values when it is stored.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 31/Jan/11 ]

Added a note on SERVER-1627

Comment by Scott Hernandez (Inactive) [ 31/Jan/11 ]

Maybe the right time is when we transition to the createIndex command over inserting into the collection.

Comment by Eliot Horowitz (Inactive) [ 31/Jan/11 ]

Definitely a larger change, but I'd rather go to the fully correct solution at some point, then a mediocre interim solution.

Comment by Scott Hernandez (Inactive) [ 31/Jan/11 ]

They are both breaking changes, but it seems like validation and exceptions will break more existing code. I'm all behind that, but it seems like a larger user-facing change.

Comment by Eliot Horowitz (Inactive) [ 31/Jan/11 ]

I don't want to change the value you put in.
So the only change I would make is throwing an exception on an invalid key, which is definitely not a bad idea per se.

Comment by Scott Hernandez (Inactive) [ 31/Jan/11 ]

I understand being lenient and I'm not asking for validation or exceptions just recording of consistent values. In the indexing code each index is create either ascending, descending, or 2d (geo).

When writing an administrative app you need some consistency.

Comment by Eliot Horowitz (Inactive) [ 31/Jan/11 ]

"foo" in general would be an index type.
like "2d".
There will be many more index types.

Now arguably we should throw an exception for an invalid index, but we decided not to a while ago since we didn't want to break users.
There are a number of people with "1" instead of 1 for example.

Comment by Scott Hernandez (Inactive) [ 31/Jan/11 ]

What does "foo" mean in this context?

Comment by Eliot Horowitz (Inactive) [ 31/Jan/11 ]

"foo" is valid.

Generated at Thu Feb 08 02:59:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.