]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
pep484 ORM / SQL result support
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Apr 2022 01:06:41 +0000 (21:06 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 27 Apr 2022 18:46:36 +0000 (14:46 -0400)
commitad11c482e2233f44e8747d4d5a2b17a995fff1fa
tree57f8ddd30928951519fd6ac0f418e9cbf8e65610
parent033d1a16e7a220555d7611a5b8cacb1bd83822ae
pep484 ORM / SQL result support

after some experimentation it seems mypy is more amenable
to the generic types being fully integrated rather than
having separate spin-off types.   so key structures
like Result, Row, Select become generic.  For DML
Insert, Update, Delete, these are spun into type-specific
subclasses ReturningInsert, ReturningUpdate, ReturningDelete,
which is fine since the "row-ness" of these constructs
doesn't happen until returning() is called in any case.

a Tuple based model is then integrated so that these
objects can carry along information about their return
types.  Overloads at the .execute() level carry through
the Tuple from the invoked object to the result.

To suit the issue of AliasedClass generating attributes
that are dynamic, experimented with a custom subclass
AsAliased, but then just settled on having aliased()
lie to the type checker and return `Type[_O]`, essentially.
will need some type-related accessors for with_polymorphic()
also.

Additionally, identified an issue in Update when used
"mysql style" against a join(), it basically doesn't work
if asked to UPDATE two tables on the same column name.
added an error message to the specific condition where
it happens with a very non-specific error message that we
hit a thing we can't do right now, suggest multi-table
update as a possible cause.

Change-Id: I5eff7eefe1d6166ee74160b2785c5e6a81fa8b95
65 files changed:
lib/sqlalchemy/engine/__init__.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/events.py
lib/sqlalchemy/engine/interfaces.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/engine/row.py
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/asyncio/result.py
lib/sqlalchemy/ext/asyncio/scoping.py
lib/sqlalchemy/ext/asyncio/session.py
lib/sqlalchemy/ext/instrumentation.py
lib/sqlalchemy/orm/_orm_constructors.py
lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/context.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/orm/query.py
lib/sqlalchemy/orm/scoping.py
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/orm/state.py
lib/sqlalchemy/orm/util.py
lib/sqlalchemy/sql/__init__.py
lib/sqlalchemy/sql/_selectable_constructors.py
lib/sqlalchemy/sql/_typing.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/coercions.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/crud.py
lib/sqlalchemy/sql/dml.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/functions.py
lib/sqlalchemy/sql/roles.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/sql/util.py
lib/sqlalchemy/sql/visitors.py
lib/sqlalchemy/util/langhelpers.py
lib/sqlalchemy/util/typing.py
pyproject.toml
test/base/test_result.py
test/ext/mypy/plain_files/association_proxy_one.py
test/ext/mypy/plain_files/engine_inspection.py
test/ext/mypy/plain_files/experimental_relationship.py
test/ext/mypy/plain_files/hybrid_one.py
test/ext/mypy/plain_files/hybrid_two.py
test/ext/mypy/plain_files/session.py
test/ext/mypy/plain_files/sql_operations.py
test/ext/mypy/plain_files/trad_relationship_uselist.py
test/ext/mypy/plain_files/traditional_relationship.py
test/ext/mypy/plain_files/typed_queries.py [new file with mode: 0644]
test/ext/mypy/plain_files/typed_results.py [new file with mode: 0644]
test/ext/mypy/plugin_files/dataclasses_workaround.py
test/ext/mypy/test_mypy_plugin_py3k.py
test/orm/test_froms.py
test/orm/test_query.py
test/sql/test_metadata.py
test/sql/test_resultset.py
test/sql/test_select.py
test/sql/test_update.py
tools/generate_proxy_methods.py
tools/generate_tuple_map_overloads.py [new file with mode: 0644]