1
0
Fork 0

fixed deleting indexes by numeric id

This commit is contained in:
Jan Steemann 2013-02-25 13:52:50 +01:00
parent edc3d9bac6
commit bed09cbbe2
2 changed files with 29 additions and 1 deletions

View File

@ -6233,7 +6233,7 @@ TRI_index_t* TRI_LookupIndexByHandle (const CollectionNameResolver& resolver,
assert(collection->_collection != 0);
// extract the document identifier and revision from a string
if (val->IsString() || val->IsStringObject()) {
if (val->IsString() || val->IsStringObject() || val->IsNumber()) {
if (! IsIndexHandle(val, collectionName, iid)) {
*err = TRI_CreateErrorObject(TRI_ERROR_ARANGO_INDEX_HANDLE_BAD,
"<index-handle> must be an index-handle");

View File

@ -141,6 +141,34 @@ function indexSuite() {
assertEqual(false, res);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief drop index by id string
////////////////////////////////////////////////////////////////////////////////
testDropIndexString : function () {
// pick up the numeric part (starts after the slash)
var id = collection.ensureGeoIndex("a").id.substr(cn.length + 1);
var res = collection.dropIndex(collection.name() + "/" + id);
assertEqual(true, res);
res = collection.dropIndex(collection.name() + "/" + id);
assertEqual(false, res);
id = collection.ensureGeoIndex("a").id.substr(cn.length + 1);
res = collection.dropIndex(parseInt(id, 10));
assertEqual(true, res);
res = collection.dropIndex(parseInt(id, 10));
assertEqual(false, res);
id = collection.ensureGeoIndex("a").id.substr(cn.length + 1);
res = internal.db._dropIndex(collection.name() + "/" + id);
assertEqual(true, res);
res = internal.db._dropIndex(collection.name() + "/" + id);
assertEqual(false, res);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief access a non-existing index
////////////////////////////////////////////////////////////////////////////////