Skip to content

Namespace is not set from Client if Model is set id. #337

@hhhhub000

Description

@hhhhub000

Environment details

  1. Runtime: Python 3.7
  2. Server: Google App Engine Standard Edition
  3. ndb library: v1.0.1

Code example

client = ndb.Client(namespace="for_test")
...
with client.context():
        entity = AAAA(
            aaaa="aaaa"
        )
        user_key = entity.put() 

        entity = BBBB(
       id="test",
            bbbb="bbbb"
        )
        user_key = entity.put() 

AAAA is created on "for_test" namespace.
But, BBBB is created on default namespace

I think namespace should be set from client. like following

mode.py

class Model(_NotEqualMixin):
....
        elif not key_parts_unspecified:
            self._key = Key(
                self._get_kind(),
                id_,
                parent=parent,
                project=project,
                namespace=namespace or client.namespace,
            )

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions