]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
pep484: schema API
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 13 Apr 2022 13:45:29 +0000 (09:45 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 15 Apr 2022 14:29:23 +0000 (10:29 -0400)
commitc932123bacad9bf047d160b85e3f95d396c513ae
tree3f84221c467ff8fba468d7ca78dc4b0c158d8970
parent0bfb620009f668e97ad3c2c25a564ca36428b9ae
pep484: schema API

implement strict typing for schema.py

this module has lots of public API, lots of old decisions
and very hard to follow construction sequences in many
cases, and is also where we get a lot of new feature requests,
so strict typing should help keep things clean.

among improvements here, fixed the pool .info getters
and also figured out how to get ColumnCollection and
related to be covariant so that we may set them up
as returning Column or ColumnClause without any conflicts.

DDL was affected, noting that superclasses of DDLElement
(_DDLCompiles, added recently) can now be passed into
"ddl_if" callables; reorganized ddl into ExecutableDDLElement
as a new name for DDLElement and _DDLCompiles renamed to
BaseDDLElement.

setting up strict also located an API use case that
is completely broken, which is connection.execute(some_default)
returns a scalar value.   This case has been deprecated
and new paths have been set up so that connection.scalar()
may be used.  This likely wasn't possible in previous
versions because scalar() would assume a CursorResult.

The scalar() change also impacts Session as we have explicit
support (since someone had reported it as a regression)
for session.execute(Sequence()) to work.  They will get the
same deprecation message (which omits the word "Connection",
just uses ".execute()" and ".scalar()") and they can then
use Session.scalar() as well.  Getting this to type
correctly while still supporting ORM use cases required
some refactoring, and I also set up a keyword only delimeter
for Session.execute() and related as execution_options /
bind_arguments should always be keyword only, applied these
changes to AsyncSession as well.

Additionally simpify Table __init__ now that we are Python
3 only, we can have positional plus explicit kwargs finally.
Simplify Column.__init__ as well again taking advantage
of kw only arguments.

Fill in most/all __init__ methods in sqltypes.py as
the constructor for types is most of the API.   should
likely do this for dialect-specific types as well.

Apply _InfoType for all info attributes as should have been
done originally and update descriptor decorators.

Change-Id: I3f9f8ff3f1c8858471ff4545ac83d68c88107527
58 files changed:
doc/build/changelog/unreleased_20/7631.rst
doc/build/changelog/unreleased_20/exec_default.rst [new file with mode: 0644]
doc/build/core/constraints.rst
doc/build/core/ddl.rst
doc/build/core/metadata.rst
lib/sqlalchemy/__init__.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/mock.py
lib/sqlalchemy/ext/associationproxy.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/compiler.py
lib/sqlalchemy/ext/hybrid.py
lib/sqlalchemy/orm/base.py
lib/sqlalchemy/orm/descriptor_props.py
lib/sqlalchemy/orm/interfaces.py
lib/sqlalchemy/orm/persistence.py
lib/sqlalchemy/orm/scoping.py
lib/sqlalchemy/orm/session.py
lib/sqlalchemy/pool/base.py
lib/sqlalchemy/schema.py
lib/sqlalchemy/sql/__init__.py
lib/sqlalchemy/sql/_typing.py
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/cache_key.py
lib/sqlalchemy/sql/coercions.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/ddl.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/events.py
lib/sqlalchemy/sql/functions.py
lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/sql/selectable.py
lib/sqlalchemy/sql/sqltypes.py
lib/sqlalchemy/sql/util.py
lib/sqlalchemy/testing/assertsql.py
lib/sqlalchemy/util/_collections.py
lib/sqlalchemy/util/_py_collections.py
lib/sqlalchemy/util/langhelpers.py
lib/sqlalchemy/util/preloaded.py
lib/sqlalchemy/util/typing.py
pyproject.toml
test/dialect/oracle/test_dialect.py
test/engine/test_execute.py
test/ext/asyncio/test_session_py3k.py
test/ext/mypy/plain_files/core_ddl.py [new file with mode: 0644]
test/ext/test_compiler.py
test/orm/test_events.py
test/orm/test_session.py
test/profiles.txt
test/sql/test_constraints.py
test/sql/test_defaults.py
test/sql/test_returning.py
test/sql/test_sequences.py