-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
api: datastoreIssues related to the googleapis/python-ndb API.Issues related to the googleapis/python-ndb API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
I encountered an issue while migrating to cloud ndb. When querying entities based on a value contained in a StructuredProperty the structured property does not use code name but uses the datastore name instead. Below is a short code to replicate the issue
from google.cloud import ndb
class StructPropModel(ndb.Model):
code_name = ndb.IntegerProperty('datastore_name')
class EntityModel(ndb.Model):
structured_variable = ndb.StructuredProperty(StructPropModel)
def test_error():
test_entity = EntityModel()
test_entity.structured_variable = StructPropModel(code_name=1)
test_entity.put()
results = EntityModel.query(EntityModel.structured_variable.code_name == 1).count()
# Raises
# AttributeError: Model subclass StructPropModel has no attribute code_name
For completeness sake, the issue occurred on python 2.7 using google-cloud-ndb 1.2.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the googleapis/python-ndb API.Issues related to the googleapis/python-ndb API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.