Docs are bad:

- `another_example_id: TypeIDType = AnotherExample.foreign_key(nullable=True)` nullable should be able to be defined via types
- JSON field, specifically JSONB https://github.com/tiangolo/sqlmodel/discussions/696 and https://github.com/fastapi/sqlmodel/discussions/1105
- One-to-many relationships
- Data validation https://github.com/tiangolo/sqlmodel/issues/52
- Aggregate functions, like count
- Select on joined data
- One-to-one and one-to-many at the same time

TODO

- [ ] nested sessions, maybe only with connections
- [ ] tests for polyfactory support, setting session across all factories
- [ ] sessions in tests, they don't work right now
- [ ] snake case for attributes https://github.com/sqlalchemy/sqlalchemy/issues/7149
- [ ] compound unique constraints don't have great names
- [ ] https://grok.com/share/bGVnYWN5_7bfd5140-2351-4e4f-a8ba-bdedb59ac1e1 figure out better json tracking

find_or_create

```
    @staticmethod
    def find_or_create_from_scrape(scrape: "Scrape", normalized_scrape_data: StoreScrape):
        if menu := Menu.get(
            digital_channel=normalized_scrape_data.digital_channel, channel_id=normalized_scrape_data.channel_id
        ):
            return menu

        assert scrape.id
        assert normalized_scrape_data.normalized_url
        assert normalized_scrape_data.channel_id

        menu = Menu(
            originating_scrape_id=scrape.id,
            name=normalized_scrape_data.name,
            channel_id=normalized_scrape_data.channel_id,
            url=normalized_scrape_data.normalized_url,
        ).save()

        return menu

```

clear engine

```
# def clear_engine():
#     global _engine, _connection

#     if _engine:
#         _engine.dispose()
#         _engine = None
#         _connection = None
```

---

There should be a better way to add unique keys

```
    __table_args__ = (
        # users should never see two schemas with the same name
        UniqueConstraint("note_type", "doctor_id", name="doctor_and_note_type_unique"),
    )
```