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

Add constraints #28

Open
Nathan-Riviere opened this issue Apr 26, 2021 · 2 comments
Open

Add constraints #28

Nathan-Riviere opened this issue Apr 26, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@Nathan-Riviere
Copy link

Hi,

Is it possible to add the constraints?
I have in my model :

class Test(BaseModel):
id = PrimaryKeyField(unique=True)
quantity = IntegerField(constraints=[Check('quantity > 0')])

And in my migration :

class Test(BaseModel):
id = PrimaryKeyField(unique=True)
quantity = IntegerField()

My constraint is ignored by the migration module.

Thanks.

@spumer
Copy link
Owner

spumer commented Apr 26, 2021

Hi. Sure, i will check it

@spumer spumer added the enhancement New feature or request label Apr 26, 2021
@Nathan-Riviere
Copy link
Author

Thanks,

Another alternative for setting constraints is as follows:

class Test(BaseModel):
-id = PrimaryKeyField(unique=True)
-quantity = IntegerField()
-class Meta:
--constraints = [Check('quantity > 0')]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants