From 22cab7dfea3fb58b53fece97ea9651132647ac0b Mon Sep 17 00:00:00 2001 From: Jonas Brunsgaard Date: Mon, 11 Jan 2016 18:01:12 +0100 Subject: [PATCH] Support for python Decimal class (used by pgsql type Numeric) --- flask_potion/manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flask_potion/manager.py b/flask_potion/manager.py index 508946e..05f5444 100644 --- a/flask_potion/manager.py +++ b/flask_potion/manager.py @@ -5,6 +5,7 @@ from .instances import Pagination from .exceptions import ItemNotFound from .filters import FILTER_NAMES, FILTERS_BY_TYPE, filters_for_fields +import decimal class Manager(object): """ @@ -98,7 +99,8 @@ def _get_field_from_python_type(python_type): list: Array, dict: Object, datetime.date: Date, - datetime.datetime: DateTime + datetime.datetime: DateTime, + decimal.Decimal: Number, }[python_type] except KeyError: raise RuntimeError('No appropriate field class for "{}" type found'.format(python_type)) @@ -315,4 +317,4 @@ def read(self, id): if query is None: raise ItemNotFound(self.resource, id=id) - return self._query_filter_by_id(query, id) \ No newline at end of file + return self._query_filter_by_id(query, id)