9

I have the following resource defined:

item = {
    'wrapper': {
        'type': 'dict',
        'schema': {
            'element': {
                'type': 'objectid',
                'data_relation': {
                    'resource': 'code',
                    'field': '_id',
                    'embeddable': True,
                },
            },
        },
    },
}

When I try to query using the objectid, I get empty list.

http://127.0.0.1:5000/item?where={"wrapper.element":"5834987589b0dc353b72c27d"}

5834987589b0dc353b72c27d is the valid _id for the element.

If I move the data relation out of the embedded document I can query it as expected

Is there anyway to do this with an embedded data relation?

Cheyn Shmuel
  • 428
  • 8
  • 15
fullerja
  • 143
  • 1
  • 11
  • Are you sure you have an `item` inserted with `5834987589b0dc353b72c27d` as value for wrapper.element? – gcw May 05 '17 at 11:06
  • This is functionality still needed.Refer this link https://github.com/pyeve/eve-sqlalchemy/issues/100 – bigbounty May 07 '17 at 18:57
  • @bigbounty, the issue mentioned is not about the same thing. This one is just about filtering based on a objectid data_relation value, and the other is about embedding "sub-sub" documents as far as I can see. – gcw May 08 '17 at 13:20
  • Yes, I do have an item with the ID that I am querying for – fullerja May 08 '17 at 13:50
  • can we have the field in data relation set to some other field in referenced resorce? for example can I have 'id' instead of '_id'? Assuming that I have a field in the referenced table by that name. – Eswar Feb 13 '19 at 11:08

2 Answers2

1

I have just tested with eve==0.7.1 and it works as expected by filtering with ?where={"wrapper.element" : "<your_objectid>"}, as you said.

gcw
  • 1,639
  • 1
  • 18
  • 37
  • Tested on 0.7.3 and it doesn't work for me, maybe it is some other part of my schema that is busting this. I will try a bare bones application – fullerja May 11 '17 at 16:42
0

I had a problem where the _id was being stored as a string rather than an ObjectId(), this broke the query

fullerja
  • 143
  • 1
  • 11