From 959f3802187de63cced7a68c21cccbb174379795 Mon Sep 17 00:00:00 2001 From: Andrew Bolster Date: Thu, 26 Aug 2021 07:58:46 +0200 Subject: [PATCH 1/2] Update GUID handling use stdlib UUID.hex Rather than integer based serialization grandfathered in from sqlalchemy, use the stdlib [`UUID.hex`](https://docs.python.org/3/library/uuid.html#uuid.UUID.hex) method. This also fixes #25 --- sqlmodel/sql/sqltypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlmodel/sql/sqltypes.py b/sqlmodel/sql/sqltypes.py index e7b77b8c52..ac9dd773fc 100644 --- a/sqlmodel/sql/sqltypes.py +++ b/sqlmodel/sql/sqltypes.py @@ -46,10 +46,10 @@ def process_bind_param(self, value, dialect): return str(value) else: if not isinstance(value, uuid.UUID): - return f"{uuid.UUID(value).int:x}" + return uuid.UUID(value).hex else: # hexstring - return f"{value.int:x}" + return value.hex def process_result_value(self, value, dialect): if value is None: From 182f24ad9fc542cffbec9fa42beb0deab2ea3dea Mon Sep 17 00:00:00 2001 From: Mathias Nisted Velling Date: Sun, 19 Dec 2021 09:41:19 +0100 Subject: [PATCH 2/2] Default index to False in field --- sqlmodel/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 08eaf5956f..0b9bff3bde 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -151,7 +151,8 @@ def Field( primary_key: bool = False, foreign_key: Optional[Any] = None, nullable: Union[bool, UndefinedType] = Undefined, - index: Union[bool, UndefinedType] = Undefined, + # NOTE: Undefined not propagating well to postgres - explicitly set False + index: Union[bool, UndefinedType] = False, sa_column: Union[Column, UndefinedType] = Undefined, # type: ignore sa_column_args: Union[Sequence[Any], UndefinedType] = Undefined, sa_column_kwargs: Union[Mapping[str, Any], UndefinedType] = Undefined,