]> 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:14:03 +0000 (00:14 +0200)
commit46304b3afdaaa387c4ae41770e4fe2079bda749d
treedb58357c49987151554c190c088579291002723d
parent64503b9eded3f5f6bd1591a44b6f42b2c4b9b304
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
(cherry picked from commit 7b9ee3daea9e22f3ec1babe7130b3885802e25af)
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