Skip to content

Commit d54037e

Browse files
committed
fixed default validators for reference field to a table without _id
1 parent 32e9ead commit d54037e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pydal/validators.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,12 +635,15 @@ def __init__(
635635
self.dbset = dbset
636636

637637
table = None
638-
if isinstance(field, Table):
638+
# if it is a table with an id
639+
if isinstance(field, Table) and hasattr(table, "_id"):
639640
table = field
640641
field = table._id
641642
fname = str(field)
643+
# if it is a field
642644
if isinstance(field, Field):
643645
fname = str(field)
646+
# if it is a table.field name
644647
elif isinstance(field, str):
645648
items = field.split(".")
646649
if len(items) == 1 or items[1] == "id":

0 commit comments

Comments
 (0)