Skip to content

Commit cf2897e

Browse files
committed
sqlmodel: handle forwardref
1 parent e5ad22d commit cf2897e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fquery/sqlmodel.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ def decorator(cls):
194194
if many_to_one:
195195
type_class = cfield.type
196196
other_class = type_class.__args__[0]
197-
other_class = getattr(other_class, "__name__", None)
197+
if isinstance(other_class, ForwardRef):
198+
other_class = other_class.__forward_arg__
199+
other_class = getattr(other_class, "__name__", other_class)
198200
key_table_name = default_table_name(other_class)
199201
key_column_name = sql_meta.get(
200202
"key_column_name", f"{key_table_name}.id"

0 commit comments

Comments
 (0)