From 4213c978fc17b6f57337c43295adffd75eb554e4 Mon Sep 17 00:00:00 2001 From: honglei Date: Fri, 25 Aug 2023 22:12:34 +0800 Subject: [PATCH] support AnyURL --- sqlmodel/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 14dbffd..dbc05c4 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -461,8 +461,11 @@ def get_sqlalchemy_type(field: FieldInfo) -> Any: # UrlConstraints(max_length=512, # allowed_schemes=['smb', 'ftp', 'file']) ] if type_ is pydantic.AnyUrl: - meta = field.metadata[0] - return AutoString(length=meta.max_length) + if field.metadata: + meta = field.metadata[0] + return AutoString(length=meta.max_length) + else: + return AutoString org_type = get_origin(type_) if org_type is Annotated: