-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Description
Since slashes are not valid as document _key values, and I need to have URLs as document _key, I was URL encoding them before assigning them as _key. However, when I was using db.document(_id)
or db.collection("collection-name"). get(_key)
, the functions return None. When I used db.collection("collection-name").find({"_id": _id)
, however, the document was found.
I'm using python 3.7, arango 3.4.4, and python-arango 4.4.0
Below is a minimal example to reproduce the issue:
from urllib.parse import quote_plus
from arango import ArangoClient
client = ArangoClient(protocol='http', host='localhost', port=8529)
sys_db = client.db('_system')
if not sys_db.has_database('test'):
sys_db.create_database('test')
db = client.db("test")
if db.has_collection('collection1'):
c = db.collection('collection1')
else:
c = db.create_collection('collection1')
url_encoded = quote_plus("http://google.com")
c.insert({"_key": url_encoded})
print(db.document(f"collection1/{url_encoded}"))
# prints: None
print(db.collection("collection1").get(url_encoded))
# prints: None
print(db.collection("collection1").find({"_id": f"collection1/{url_encoded}"}).next())
# prints: {'_key': 'http%3A%2F%2Fgoogle.com', '_id': 'collection1/http%3A%2F%2Fgoogle.com', '_rev': '_YpqexJK---'}
Metadata
Metadata
Assignees
Labels
No labels