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

Biginteger field #549

Closed
wants to merge 2 commits into from
Closed

Conversation

ddorian
Copy link
Contributor

@ddorian ddorian commented Sep 5, 2023

I was using https://github.com/schemathesis/schemathesis to test my openapi, and the first thing it did was to send a out-of-range bigint, that was accepted by python, but actually errored in PostgreSQL (sqlalchemy.exc.DataError: (psycopg.errors.NumericValueOutOfRange) bigint out of range).

So I created a BigInteger field that checks that.

@lafrech
Copy link
Member

lafrech commented Sep 5, 2023

Thanks for bringing this up and sharing your implementation.

I won't integrate this here. It would be better suited for marshmallow itself, it is not specific to flask-smorest.

Regarding the implementation itself, couldn't you use a Range validator?

I'm wondering if it makes sense to integrate a PostgreSQL specific field in marshmallow if it is as easy for the user as specifying an existing validator.

Perhaps marshmallow-sqlalchemy could add that validator automatically or integers.

@ddorian
Copy link
Contributor Author

ddorian commented Sep 6, 2023

Regarding the implementation itself, couldn't you use a Range validator?

Is there a way to add a "default" validator to all instances of a class? Otherwise I'd have to repeat it often, no?

Perhaps marshmallow-sqlalchemy could add that validator automatically or integers.

Maybe.

Thank you.

@ddorian ddorian closed this Sep 6, 2023
@lafrech
Copy link
Member

lafrech commented Sep 10, 2023

You may subclass the field, like you already do, to add this validator by default.

@lafrech
Copy link
Member

lafrech commented Sep 11, 2023

My point was that it seemed better to me to use the existing validator that write comparisons.

Regarding marshmallow integration, see See marshmallow-code/marshmallow#2182.

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

Successfully merging this pull request may close these issues.

2 participants