Actions
Issue #1332
closedin Search API, restritcting fields does not work with Mongoengine
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
2.7.0
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:
Description
The `fields` machinery works only with models before the switch to mongoengine.
When sending a criteria object to pymongo, the fields key restricts the fields of the dictionary that is returned. This doesn't work because Mongoengine objects are hydrated from those dictionaries, and instead of leaving them off at serialization time, they are simply set to null values.
$ http --json -a admin:admin --verify=no POST https://localhost/pulp/api/v2/repositories/search/ criteria:='{"filters": {"id": "zoo"}}'
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 296
Content-Type: application/json; charset=utf-8
Date: Thu, 22 Oct 2015 20:32:00 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.16 (Fedora) OpenSSL/1.0.1k-fips mod_wsgi/4.4.8 Python/2.7.10
[
{
"_href": "/pulp/api/v2/repositories/zoo/",
"_id": {
"$oid": "562946cfe779894f63353553"
},
"_ns": "repos",
"content_unit_counts": {},
"description": null,
"display_name": null,
"id": "zoo",
"last_unit_added": null,
"last_unit_removed": null,
"notes": {
"_repo-type": "rpm-repo"
},
"scratchpad": {}
}
]
$ http --json -a admin:admin --verify=no POST https://localhost/pulp/api/v2/repositories/search/ criteria:='{"filters": {"id": "zoo"}, "fields": ["id"]}'
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 272
Content-Type: application/json; charset=utf-8
Date: Thu, 22 Oct 2015 20:32:11 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.16 (Fedora) OpenSSL/1.0.1k-fips mod_wsgi/4.4.8 Python/2.7.10
[
{
"_href": "/pulp/api/v2/repositories/zoo/",
"_id": {
"$oid": "562946cfe779894f63353553"
},
"_ns": "repos",
"content_unit_counts": {},
"description": null,
"display_name": null,
"id": "zoo",
"last_unit_added": null,
"last_unit_removed": null,
"notes": {},
"scratchpad": {}
}
]
Related issues
Actions
Allow restriction of fields on Mongoengine documents
closes #1332 cloese #1417
Remove unspecified, nonrequired key value pairs from serialized results when searching by a criteria object that specifies
fields
.