Have id of string type
ricardo8990 opened this issue · 2 comments
Currently id
always has to be of type int
. However, there're many cases where the id
is a String type (using a uuid for instance).
Is there any restriction on Redis that id
has always to be an int
?
Tried this, but it seems that I can't name any field id
rather than the PrimaryKey
:
class MyModel(Model):
id = String(default=my_uuid_function, required=True, index=True, keygen=util.IDENTITY)
o_id = PrimaryKey()
...
Would be great to be able to have id
with different types and use a default function.
Is there any restriction on Redis that id has always to be an int?
There isn't a Redis restriction, but my library, rom
keeps an integer primary key generally because then I can enforce a certain level of data sanity and uniqueness (much like rowids in sqlite and similar). Reading the library code, and verifying, as long as you define a name for the primary key, you should be okay. It should be letting you do it, and it should only be complaining if you omitted it entirely.
More specifically: the above code you wrote works. Is it not working for you?
You're right, I double checked my code and the above code actually works. Thanks for your help