googleapis/python-ndb

get_or_insert doesn't allow passing values for fields named 'name' or 'cls'

Closed this issue · 0 comments

On the App Engine NDB library, the Model.get_or_insert function allowed you to pass model keyword arguments with the name "name". In Cloud NDB, if you have a Model with a property called name, you can't pass a value for it to get_or_insert (see here: https://github.com/googleapis/python-ndb/blob/main/google/cloud/ndb/model.py#L5865)

Steps to reproduce

  1. Create a Model with an id and name property
  2. Try to use get_or_insert, passing an ID, and name= to populate the name property

What you get is this:

  /usr/bin/nano +89  .env/lib/python3.9/site-packages/google/cloud/ndb/_options.py  # wrapper
    return wrapped(*pass_args, **kwargs)
  /usr/bin/nano +153 .env/lib/python3.9/site-packages/google/cloud/ndb/utils.py  # positional_wrapper
    return wrapped(*args, **kwds)
TypeError: _get_or_insert() got multiple values for argument 'name'