sqlalchemy-stubs icon indicating copy to clipboard operation
sqlalchemy-stubs copied to clipboard

Add support for foreign keys

Open ilevkivskyi opened this issue 7 years ago • 3 comments

We could add a plugin that would allow to infer types for keys referenced by their names in other tables/models. This would likely require some extensive changes to mypy (because of implicit dependencies between modules/targets), so this is low priority.

ilevkivskyi avatar Aug 27 '18 15:08 ilevkivskyi

A more important use case here, is to automatically infer RelationshipProperty[Cls] for relationship('Cls', ...) (note the string literal). There is a simple way to implement this, but it requires Cls to be available (imported) in the current scope (at least under if typing.TYPE_CHECKING: ...).

ilevkivskyi avatar Nov 04 '18 21:11 ilevkivskyi

Actually the relationship use case looks important (and there is a simple although limited way to implement this), so raising priority to normal.

ilevkivskyi avatar Nov 04 '18 21:11 ilevkivskyi

Note that the relationship part was partially implemented in #49.

ilevkivskyi avatar Jan 16 '19 22:01 ilevkivskyi