Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnumField #44

Closed
Jaymon opened this issue Jun 8, 2017 · 1 comment
Closed

EnumField #44

Jaymon opened this issue Jun 8, 2017 · 1 comment
Labels

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jun 8, 2017

a field that converts to an int behind the scenes, but allows the live object to have a set of values, so you could do something like:

class Foo(Orm):
  bar = EnumField("a", "b", "c", "d")

f = Foo()
f.bar = ["a", "b"]
f.save() # bar will save into the db as 3

f2 = f.query.get_pk(f.pk)
f2.bar # ["a", "b"]

So the enum field will set the appropriate field setters to make sure the the live orm always has a set of values, and that the db always gets the int, when it creates the field it takes the values you passed into it and sets their values in the order they are passed in, doubling the value as it goes, so

EnumField("a", "b", "c", "d")
a = 1
b = 2
c = 4
d = 8
@Jaymon Jaymon added the wontfix label Jul 23, 2022
@Jaymon
Copy link
Owner Author

Jaymon commented Jul 23, 2022

I think this is actually superceded by extras.config.Field's enum support

@Jaymon Jaymon closed this as completed Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant