marshmallow-code / marshmallow-code/marshmallow

[RFC] Add BigInt, SmallInt,... fields.

Open
#2,182 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
738
Avg merge
1d 23h
Merged PRs (30d)
7

Description

Originally in https://github.com/marshmallow-code/flask-smorest/pull/549.

One may add a range validator to every int field in their code base but that is cumbersome. Or subclass the Integer field to create a dedicated field, but it is a pity to do it in every code base if it can be done here.

Since this seems to be a common need, and the vocabulary seems to be shared across databases (https://www.postgresql.org/docs/current/datatype-numeric.html, https://learn.microsoft.com/fr-fr/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql), perhaps we could provide dedicated fields in marshmallow.

```
- BigInteger(Integer) -> Range(-2**63+1,2**63-1)
- SmallInteger(Integer) -> 2**8
```

I don't know how we'd call 2**32 Integer without breaking current Integer field.

Or we make this a parameter of Integer. But I think a dedicated class is nicer to use.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Integer field and the requirements in the referenced flask-smorest PR. Resolve the proposed class names, numeric ranges, and whether this should be implemented as dedicated fields or an Integer parameter. Done means the API and range semantics have agreement before implementation begins.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.