diff options
author | Andy Freeland <andy@andyfreeland.net> | 2023-04-20 13:41:39 -0400 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2023-04-20 20:55:21 +0200 |
commit | c1125288e3c413d868070995b308085d2ddf402e (patch) | |
tree | cb8e1e04ed56a67d7ddd9bd19c2e727206fa95c1 /lib/sqlalchemy/dialects/postgresql/base.py | |
parent | fc2bcead435a9bf0a2de8e9b15a1bd835f9d7fe4 (diff) | |
download | sqlalchemy-c1125288e3c413d868070995b308085d2ddf402e.tar.gz |
Fix `RowMapping`'s `Mapping` type to reflect that it supports `Column`s or strings
### Description
I ran into this originally in sqlalchemy2-stubs: https://github.com/sqlalchemy/sqlalchemy2-stubs/pull/251, where `RowMapping` only supported string keys according to the type hints. I ran into a similar issue here upgrading our application where because `RowMapping` subclassed `Mapping[str, Any]`, `Row._mapping.get()` would fail to typecheck when used with `Column` objects.
This patch adds a test to verify that `Row._mapping.get()` continues to work with both strings and `Column`s, though it doesn't look like mypy checks types in the tests.
Fixes #9644.
### 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:
- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] A short code fix
- please include the issue number, and create an issue if none exists, which
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests. one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.
**Have a nice day!**
Closes: #9643
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/9643
Pull-request-sha: 6c33fe534cf457d6b5c73f4830a64880830f0f56
Change-Id: I1009c6defff109d73f13a9e8c51641009e6a79e2
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/base.py')
0 files changed, 0 insertions, 0 deletions