dreamwalker
dreamwalker

Reputation: 1743

is it safe to use non-English characters for the ID part of a datastore key?

I would like to give my users the option of including non-English characters in their usernames.

For simplicity's sake (and to avoid subtle bugs) I would then like to use their username as the id part of the ndb key for their Entity. My question is, is this a safe approach?

I was unable to find information on whether GAE datastore supports non-English characters as the id part of a key.

Upvotes: 1

Views: 109

Answers (1)

OmegaDirective
OmegaDirective

Reputation: 366

Straight from the horse's mouth, the source code (the key class):

  • Kinds and string ids must not be empty and must be at most 500 bytes long (after UTF-8 encoding, if given as Python unicode objects).

If UTF-8 is used you should be able to use any language you want. Also, from this doc:

The next component is an ID (int64) or key name (str).

'str' as defined on the top of the page suggests non-ASCII chars are accepted.

p.s. Using usernames as unique IDs has some disadvantages; See this discussion (ignore the SQL aspect of it.)

Upvotes: 3

Related Questions