From b2d87e59c86663f809efc212dc6bedf6fb6a6ca0 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 21 Sep 2021 16:40:31 +0300 Subject: [PATCH] Don't index all fields by default The code was setting an index on every field by default. This meant that a simple model like: ```python class Foo(SQLModel, table=True): a: str b: int c: str ``` Would have indices for all fields. This is wrong, the default should be to not create an index. --- sqlmodel/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index 661276b31d..f745b244a9 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -417,7 +417,7 @@ def get_column_from_field(field: ModelField) -> Column: nullable = not field.required index = getattr(field.field_info, "index", Undefined) if index is Undefined: - index = True + index = False if hasattr(field.field_info, "nullable"): field_nullable = getattr(field.field_info, "nullable") if field_nullable != Undefined: