From e80a5adfd406e2392cfaad687e8b3f0ae9ed4e11 Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Wed, 22 Nov 2017 10:05:44 +0000 Subject: [PATCH] Allow for the database to produce a UUID instance Some database adapters (specifically, pg8000) already produce a uuid.UUID() instance for UUID columns. Account for this. --- doc/build/core/custom_types.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/build/core/custom_types.rst b/doc/build/core/custom_types.rst index 5384d0fd42..6864e1915d 100644 --- a/doc/build/core/custom_types.rst +++ b/doc/build/core/custom_types.rst @@ -163,7 +163,9 @@ binary in CHAR(16) if desired:: if value is None: return value else: - return uuid.UUID(value) + if not isinstance(value, uuid.UUID): + value = uuid.UUID(value) + return value Marshal JSON Strings ^^^^^^^^^^^^^^^^^^^^ -- 2.47.3