Python Eve allow_unknown=True and projection (exclusion)

141 views Asked by At

I have a collection with non well defined schema. It is read-only and I am using python-eve with the option allow_unknown=True, so that it returns the whole documents even if they do not match the (non-existent) schema.

Some documents in the collection contain a heavy field named d:

{
   '_id': '...',
   'date': '2020-10-10',
   'd': {...}
}

The projection: http://url/?projection={"d":0} basically does nothing. The returned documents come with the field d. The expected behavior is to exclude the field d and include everything else.

The opposite behaviour http://url/?projection={"d":1} works well and excludes all except the field d.

Am I missing something?

1

There are 1 answers

0
Iman Shafiei On

No, you're right, I've implemented your case and got exactly what you say. The problem is that when you set allow_unknown to True, the projection is disabled.

After more investigating, found this issue on GitHub:

https://github.com/pyeve/eve/issues/1187

I think for now you should just oppositely use projection.