When setting max_digits and decimal_places to condecimal these are ignored.
The SQL CREATE TABLE resulting from the previous model city definition results in:
CREATE TABLE city (
id INTEGER AUTO_INCREMENT,
name VARCHAR(150) NOT NULL,
population INTEGER,
latitude NUMERIC NOT NULL,
longitude NUMERIC NOT NULL,
PRIMARY KEY (id)
)
So latitude and longitude are created with default parameters max_digits = 10 and decimal_places = 0.
changed the title [-]Set max_digits and decimal_places in condecimal are ignored[/-][+]Add support for Decimal in Pydantic and SQLAlchemy[/+]on Dec 13, 2021
Activity
robcxyz commented on Sep 19, 2021
I submitted a PR #103 to address this. Pydantic arguments needed to be mapped to sqlalchemy's for that type.
tiangolo commented on Dec 13, 2021
Thanks for the feedback @roomm! 🤓
This was added in @robcxyz's PR #103, it is now included in the (just released) SQLModel 0.0.5 🎉
github-actions commented on Dec 24, 2021
Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.