Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Projection queries do not work on fields of a PolyModel subclass #261

Open
cmoscardi opened this issue Dec 3, 2015 · 2 comments
Open

Projection queries do not work on fields of a PolyModel subclass #261

cmoscardi opened this issue Dec 3, 2015 · 2 comments

Comments

@cmoscardi
Copy link

Hi, the issue can be seen here on SO:
http://stackoverflow.com/questions/28250761/appengine-datastore-polymodel-and-projection

I've copied the relevant bit here for convenience...

Below I present a simpler model (removed StructuredProperty) which gives the same issue:

class Contact(polymodel.PolyModel):
    telephone = ndb.StringProperty()

class Person(Contact):
    name = ndb.StringProperty()

This works:

qry = Person.query(projection=['telephone'])

This does not work:

qry = Person.query(projection=['name'])

In particular, the raised error is :

InvalidPropertyError: Unknown property name
@pcostell
Copy link
Contributor

pcostell commented Jan 8, 2016

I took a look through the code. The main issue is that:

model._query passes in the result of _get_kind() to query, query then uses that to lookup the Model during projection/group_by property validation. In the case of polymodel, _get_kind() returns the base class name. Then when validation happens this will fail.

This looks like a broken separation of concerns. The model's _query() method should validate that the properties are a part of the query, not the query itself. However, this isn't quite right because of gql queries where the Kind is specified in the query and then constructed without calling model.query().

@shobhitagarwal1612
Copy link

shobhitagarwal1612 commented May 14, 2019

I am also stuck on this issue. It has been quite some time since the last comment but I am still wondering if anyone could help me. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants