Azure/azure-cosmos-python

Collection link as a combination of _self and name doesn't work

Closed this issue · 3 comments

Hi,

I have a collection link as follows dbs/someDB==/colls/myCollection
When I try to delete collection with the above link, I get a BadRequest 400 exception. But, when I give the path as the database name (id), it works. So, I'm assuming either if I send both _selfs or both names, it works, but not for any other combination.
I think it would be nice to work with links which could have any combination, as DocumentDB gives us the flexibility of querying either id based or _self based.

Thanks.

Currently cosmos db doesn't support hybrid addressing.
In most scenarios name based approach will work. Are you running into any issues?

It's nice that Cosmos DB gives us the flexibility to use both types of addressing, so I thought it would
Was trying to handle this scenario where I've a database self link and collection id as follows,
`def DeleteCollectionIfExists(client, database_link, collection_id):
try:
collection_link = "dbs/{0}".format(DATABASE_ID) + "/" + 'colls/{0}'.format(collection_id)
#collection_link = database_link + 'colls/{0}'.format(collection_id)
# having some trouble with this format of querying, raised an issue
# #106

    client.DeleteCollection(collection_link)
    print('Collection with id \'{0}\' was deleted'.format(collection_id))
except errors.DocumentDBError as e:
    if e.status_code == 404:
        pass
    elif e.status_code == 400:
        print("Bad request for collection link", collection_link)
        raise
    else:
        raise`

So, do you suggest to follow name based approach only? As we can't toggle between these two approaches not so easily.

Closing this issue due to age. Active development of our Python SDK has moved to https://github.com/Azure/azure-sdk-for-python. We have also released 4.0 which includes many updates and new features. If this issue still needs our attention, please reopen it in the new repository.