]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Update `table_per_related` example for Declarative API
authorMike Fiedler <miketheman@gmail.com>
Fri, 20 Jun 2025 21:49:26 +0000 (17:49 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Fri, 20 Jun 2025 22:13:26 +0000 (00:13 +0200)
commit7b9ee3daea9e22f3ec1babe7130b3885802e25af
tree2e1742f7604ee258224248a3e7edac4b13e85214
parent33af5279bbcf77d85f3370ce36d9f81e92c63fd6
Update `table_per_related` example for Declarative API

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
When reading more of the Generic Associations, I found that the examples state "Annotated example", and wondered what that meant, since in other parts of the docs that means they are using the new 2.0 style.

I tried to update this example to be more in line with the new style, including a little f-string update.

I completely understand this is unlikely to be merged as-is - but wanted to understand more about the right way to use modern styles to properly code well-hinted, more "exotic" implementations.

Outstanding questions:
- Should examples pass pass `mypy --strict` ? It doesn't right now.
- Are there better ways to apply `Mapped` within the `type(...)` definition, so we could skip importing `Integer`?

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

(Do non-running examples count as code fixes/features?)

- [x] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed

**Have a nice day!**

Closes: #10450
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10450
Pull-request-sha: a6a54d69487429c8b3a7758cf22913e6a2156316

Change-Id: Ie7c7526daed5bf907d41f666459759b9a986b8c2
examples/generic_associations/discriminator_on_association.py
examples/generic_associations/generic_fk.py
examples/generic_associations/table_per_association.py
examples/generic_associations/table_per_related.py