marshmallow-code / marshmallow-code/flask-marshmallow
Postgres Money Type
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 887
- Forks
- 65
- Avg merge
- 7h 25m
- Merged PRs (30d)
- 3
Description
I have a sqlalchemy class with a postgres money field
`budget = db.Column(sqlalchemy.dialects.postgresql.MONEY)`
I'm using the SQLAlchemyAutoSchema to dump a record of containing this, but it is failing with the error
`decimal.InvalidOperation: []`
I'm using marshmallow-sqlalchemy 0.23.1 and SQLAlchemy 1.3.15, and as far as I understand it, the MONEY type was added https://github.com/marshmallow-code/marshmallow-sqlalchemy/pull/218
My completely uneducated guess is that the SQLA_TYPE_MAPPING is just trying to interpret the value as a decimal? However, the value in the query result object is a string, including the currency symbol. e.g. '$800.00'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the SQLAlchemyAutoSchema dump with a PostgreSQL MONEY value such as '$800.00', then inspect the SQLA_TYPE_MAPPING path mentioned in the report. Confirm how the returned currency string is converted and define done as successfully serializing the record without decimal.InvalidOperation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python, sqlalchemy
- Domain
- backend-api-design, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100