Skip to content

Commit

Permalink
feat: adds a uuid_utils encoder if it is installed (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Feb 18, 2024
1 parent 60d6727 commit 5e3eca5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions advanced_alchemy/extensions/litestar/plugins/init/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ def on_app_init(self, app_config: AppConfig) -> AppConfig:

signature_namespace_values.update({"pgproto.UUID": pgproto.UUID})
app_config.type_encoders = {pgproto.UUID: str, **(app_config.type_encoders or {})}
with contextlib.suppress(ImportError):
from uuid_utils import UUID

signature_namespace_values.update({"UUID": UUID})
app_config.type_encoders = {
**(app_config.type_encoders or {}),
UUID: str,
}
app_config.signature_namespace.update(self._config.signature_namespace)
app_config.signature_namespace.update(signature_namespace_values)
app_config.lifespan.append(self._config.lifespan)
Expand Down

0 comments on commit 5e3eca5

Please sign in to comment.