alltyme / appengine-ndb-experiment

Automatically exported from code.google.com/p/appengine-ndb-experiment
Other
0 stars 0 forks source link

ndb.KeyProperty with kind argument is renamed in properties #242

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
from google.appengine.ext import ndb

class Test(ndb.Model):
    k1 = ndb.KeyProperty()
    k2 = ndb.KeyProperty('Test')

entity = Test()
print entity._properties.keys()  # => ['Test', 'k1']

The second property, "k2", should come back as "k2", not "Test".   This causes 
problems with libraries like protorpc which depend on the _properties() method 
to recreate the model's schema.

Original issue reported on code.google.com by dustinar...@gmail.com on 2 Apr 2014 at 7:36

GoogleCodeExporter commented 9 years ago
This model should have been defined:

class Test(ndb.Model):
    k1 = ndb.KeyProperty()
    k2 = ndb.KeyProperty(kind='Test')

Failing to specify the kind= means this gets interpreted as the Property 
constructor argument name, allowing you to name the property.

Original comment by pcoste...@google.com on 2 Apr 2014 at 9:33