Describe the bug
From v1.21.0, init_beanie no longer supports initializing models with nullable indexed field. Instead it raises AttributeError: _indexed in the init_indexes method
To Reproduce
import asyncio
from datetime import datetime
from typing import Optional
from beanie import Document, init_beanie, Indexed
class UserProfile(Document):
name: str
last_login: Optional[Indexed(datetime)]
async def main():
await init_beanie(connection_string="mongodb://localhost:27017/test", document_models=[UserProfile])
asyncio.run(main())
Expected behavior
The code snippet runs without exception and creates an index on last_login in v1.20.0 and older versions
Additional context
AttributeError was raised in v1.21.0 & v1.22.x
Pydantic version is 1.10.12
After upgrading pydantic to 2.3.0, the code runs without exception but it does not create index on last_login field,
Describe the bug From v1.21.0,
init_beanie
no longer supports initializing models with nullable indexed field. Instead it raisesAttributeError: _indexed
in theinit_indexes
methodTo Reproduce
Expected behavior The code snippet runs without exception and creates an index on
last_login
in v1.20.0 and older versionsAdditional context AttributeError was raised in v1.21.0 & v1.22.x
Pydantic version is 1.10.12 After upgrading pydantic to 2.3.0, the code runs without exception but it does not create index on
last_login
field,