From a099f10718bebf052e4a7228306bd221d80b8b68 Mon Sep 17 00:00:00 2001 From: Charles Leifer Date: Wed, 11 Mar 2026 18:34:27 -0500 Subject: [PATCH] Add mapping of field type -> py type. --- playhouse/reflection.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/playhouse/reflection.py b/playhouse/reflection.py index 0f338265..de2e2034 100644 --- a/playhouse/reflection.py +++ b/playhouse/reflection.py @@ -1,4 +1,7 @@ +import datetime +import decimal import re +import uuid import warnings from collections import OrderedDict from collections import namedtuple @@ -34,6 +37,32 @@ RESERVED_WORDS = set([ ]) +FieldTypeMap = { + 'AUTO': int, + 'BIGAUTO': int, + 'BIGINT': int, + 'BLOB': bytes, + 'BOOL': bool, + 'CHAR': str, + 'DATE': datetime.date, + 'DATETIME': datetime.datetime, + 'DECIMAL': decimal.Decimal, + 'DOUBLE': float, + 'FLOAT': float, + 'INT': int, + 'SMALLINT': int, + 'TEXT': str, + 'TIME': datetime.time, + 'UUID': uuid.UUID, + 'UUIDB': bytes, + 'VARCHAR': str, + 'JSON': dict, + 'JSONB': dict, + 'TIMESTAMPTZ': datetime.datetime, + 'INTERVAL': datetime.timedelta, +} + + class UnknownField(object): pass