[PR #315] [CLOSED] Scheduled weekly dependency update for week 11 #323

Closed
opened 2026-02-26 01:34:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jeffknupp/sandman2/pull/315
Author: @pyup-bot
Created: 3/13/2023
Status: Closed

Base: masterHead: pyup-scheduled-update-2023-03-13


📝 Commits (10+)

  • 4c58141 Update flask from 1.1.2 to 2.2.3
  • 7be1e2e Update flask-admin from 1.5.7 to 1.6.1
  • 5b1d1df Update flask-sqlalchemy from 2.4.4 to 3.0.3
  • 510f15b Update sqlalchemy from 1.3.20 to 2.0.5.post1
  • 96effcc Update wtforms from 2.3.3 to 3.0.1
  • 97a15f7 Update coverage from 5.3 to 7.2.1
  • c97dbcd Update pytest from 6.2.0 to 7.2.2
  • 201e3ec Update flask-cors from 3.0.9 to 3.0.10
  • 0d82d19 Update pytest-cov from 2.10.1 to 4.0.0
  • c9e9f75 Update pytest-flask from 1.1.0 to 1.2.0

📊 Changes

1 file changed (+15 additions, -15 deletions)

View changed files

📝 requirements.txt (+15 -15)

📄 Description

Update Flask from 1.1.2 to 2.2.3.

Changelog

2.2.3

-------------

Released 2023-02-15

-   Autoescape is enabled by default for ``.svg`` template files. :issue:`4831`
-   Fix the type of ``template_folder`` to accept ``pathlib.Path``. :issue:`4892`
-   Add ``--debug`` option to the ``flask run`` command. :issue:`4777`

2.2.2

-------------

Released 2022-08-08

-   Update Werkzeug dependency to >= 2.2.2. This includes fixes related
 to the new faster router, header parsing, and the development
 server. :pr:`4754`
-   Fix the default value for ``app.env`` to be ``"production"``. This
 attribute remains deprecated. :issue:`4740`

2.2.1

-------------

Released 2022-08-03

-   Setting or accessing ``json_encoder`` or ``json_decoder`` raises a
 deprecation warning. :issue:`4732`

2.2.0

-------------

Released 2022-08-01

-   Remove previously deprecated code. :pr:`4667`

 -   Old names for some ``send_file`` parameters have been removed.
     ``download_name`` replaces ``attachment_filename``, ``max_age``
     replaces ``cache_timeout``, and ``etag`` replaces ``add_etags``.
     Additionally, ``path`` replaces ``filename`` in
     ``send_from_directory``.
 -   The ``RequestContext.g`` property returning ``AppContext.g`` is
     removed.

-   Update Werkzeug dependency to >= 2.2.
-   The app and request contexts are managed using Python context vars
 directly rather than Werkzeug's ``LocalStack``. This should result
 in better performance and memory use. :pr:`4682`

 -   Extension maintainers, be aware that ``_app_ctx_stack.top``
     and ``_request_ctx_stack.top`` are deprecated. Store data on
     ``g`` instead using a unique prefix, like
     ``g._extension_name_attr``.

-   The ``FLASK_ENV`` environment variable and ``app.env`` attribute are
 deprecated, removing the distinction between development and debug
 mode. Debug mode should be controlled directly using the ``--debug``
 option or ``app.run(debug=True)``. :issue:`4714`
-   Some attributes that proxied config keys on ``app`` are deprecated:
 ``session_cookie_name``, ``send_file_max_age_default``,
 ``use_x_sendfile``, ``propagate_exceptions``, and
 ``templates_auto_reload``. Use the relevant config keys instead.
 :issue:`4716`
-   Add new customization points to the ``Flask`` app object for many
 previously global behaviors.

 -   ``flask.url_for`` will call ``app.url_for``. :issue:`4568`
 -   ``flask.abort`` will call ``app.aborter``.
     ``Flask.aborter_class`` and ``Flask.make_aborter`` can be used
     to customize this aborter. :issue:`4567`
 -   ``flask.redirect`` will call ``app.redirect``. :issue:`4569`
 -   ``flask.json`` is an instance of ``JSONProvider``. A different
     provider can be set to use a different JSON library.
     ``flask.jsonify`` will call ``app.json.response``, other
     functions in ``flask.json`` will call corresponding functions in
     ``app.json``. :pr:`4692`

-   JSON configuration is moved to attributes on the default
 ``app.json`` provider. ``JSON_AS_ASCII``, ``JSON_SORT_KEYS``,
 ``JSONIFY_MIMETYPE``, and ``JSONIFY_PRETTYPRINT_REGULAR`` are
 deprecated. :pr:`4692`
-   Setting custom ``json_encoder`` and ``json_decoder`` classes on the
 app or a blueprint, and the corresponding ``json.JSONEncoder`` and
 ``JSONDecoder`` classes, are deprecated. JSON behavior can now be
 overridden using the ``app.json`` provider interface. :pr:`4692`
-   ``json.htmlsafe_dumps`` and ``json.htmlsafe_dump`` are deprecated,
 the function is built-in to Jinja now. :pr:`4692`
-   Refactor ``register_error_handler`` to consolidate error checking.
 Rewrite some error messages to be more consistent. :issue:`4559`
-   Use Blueprint decorators and functions intended for setup after
 registering the blueprint will show a warning. In the next version,
 this will become an error just like the application setup methods.
 :issue:`4571`
-   ``before_first_request`` is deprecated. Run setup code when creating
 the application instead. :issue:`4605`
-   Added the ``View.init_every_request`` class attribute. If a view
 subclass sets this to ``False``, the view will not create a new
 instance on every request. :issue:`2520`.
-   A ``flask.cli.FlaskGroup`` Click group can be nested as a
 sub-command in a custom CLI. :issue:`3263`
-   Add ``--app`` and ``--debug`` options to the ``flask`` CLI, instead
 of requiring that they are set through environment variables.
 :issue:`2836`
-   Add ``--env-file`` option to the ``flask`` CLI. This allows
 specifying a dotenv file to load in addition to ``.env`` and
 ``.flaskenv``. :issue:`3108`
-   It is no longer required to decorate custom CLI commands on
 ``app.cli`` or ``blueprint.cli`` with ``with_appcontext``, an app
 context will already be active at that point. :issue:`2410`
-   ``SessionInterface.get_expiration_time`` uses a timezone-aware
 value. :pr:`4645`
-   View functions can return generators directly instead of wrapping
 them in a ``Response``. :pr:`4629`
-   Add ``stream_template`` and ``stream_template_string`` functions to
 render a template as a stream of pieces. :pr:`4629`
-   A new implementation of context preservation during debugging and
 testing. :pr:`4666`

 -   ``request``, ``g``, and other context-locals point to the
     correct data when running code in the interactive debugger
     console. :issue:`2836`
 -   Teardown functions are always run at the end of the request,
     even if the context is preserved. They are also run after the
     preserved context is popped.
 -   ``stream_with_context`` preserves context separately from a
     ``with client`` block. It will be cleaned up when
     ``response.get_data()`` or ``response.close()`` is called.

-   Allow returning a list from a view function, to convert it to a
 JSON response like a dict is. :issue:`4672`
-   When type checking, allow ``TypedDict`` to be returned from view
 functions. :pr:`4695`
-   Remove the ``--eager-loading/--lazy-loading`` options from the
 ``flask run`` command. The app is always eager loaded the first
 time, then lazily loaded in the reloader. The reloader always prints
 errors immediately but continues serving. Remove the internal
 ``DispatchingApp`` middleware used by the previous implementation.
 :issue:`4715`

2.1.3

-------------

Released 2022-07-13

-   Inline some optional imports that are only used for certain CLI
 commands. :pr:`4606`
-   Relax type annotation for ``after_request`` functions. :issue:`4600`
-   ``instance_path`` for namespace packages uses the path closest to
 the imported submodule. :issue:`4610`
-   Clearer error message when ``render_template`` and
 ``render_template_string`` are used outside an application context.
 :pr:`4693`

2.1.2

-------------

Released 2022-04-28

-   Fix type annotation for ``json.loads``, it accepts str or bytes.
 :issue:`4519`
-   The ``--cert`` and ``--key`` options on ``flask run`` can be given
 in either order. :issue:`4459`

2.1.1

-------------

Released on 2022-03-30

-   Set the minimum required version of importlib_metadata to 3.6.0,
 which is required on Python < 3.10. :issue:`4502`

2.1.0

-------------

Released 2022-03-28

-   Drop support for Python 3.6. :pr:`4335`
-   Update Click dependency to >= 8.0. :pr:`4008`
-   Remove previously deprecated code. :pr:`4337`

 -   The CLI does not pass ``script_info`` to app factory functions.
 -   ``config.from_json`` is replaced by
     ``config.from_file(name, load=json.load)``.
 -   ``json`` functions no longer take an ``encoding`` parameter.
 -   ``safe_join`` is removed, use ``werkzeug.utils.safe_join``
     instead.
 -   ``total_seconds`` is removed, use ``timedelta.total_seconds``
     instead.
 -   The same blueprint cannot be registered with the same name. Use
     ``name=`` when registering to specify a unique name.
 -   The test client's ``as_tuple`` parameter is removed. Use
     ``response.request.environ`` instead. :pr:`4417`

-   Some parameters in ``send_file`` and ``send_from_directory`` were
 renamed in 2.0. The deprecation period for the old names is extended
 to 2.2. Be sure to test with deprecation warnings visible.

 -   ``attachment_filename`` is renamed to ``download_name``.
 -   ``cache_timeout`` is renamed to ``max_age``.
 -   ``add_etags`` is renamed to ``etag``.
 -   ``filename`` is renamed to ``path``.

-   The ``RequestContext.g`` property is deprecated. Use ``g`` directly
 or ``AppContext.g`` instead. :issue:`3898`
-   ``copy_current_request_context`` can decorate async functions.
 :pr:`4303`
-   The CLI uses ``importlib.metadata`` instead of ``setuptools`` to
 load command entry points. :issue:`4419`
-   Overriding ``FlaskClient.open`` will not cause an error on redirect.
 :issue:`3396`
-   Add an ``--exclude-patterns`` option to the ``flask run`` CLI
 command to specify patterns that will be ignored by the reloader.
 :issue:`4188`
-   When using lazy loading (the default with the debugger), the Click
 context from the ``flask run`` command remains available in the
 loader thread. :issue:`4460`
-   Deleting the session cookie uses the ``httponly`` flag.
 :issue:`4485`
-   Relax typing for ``errorhandler`` to allow the user to use more
 precise types and decorate the same function multiple times.
 :issue:`4095, 4295, 4297`
-   Fix typing for ``__exit__`` methods for better compatibility with
 ``ExitStack``. :issue:`4474`
-   From Werkzeug, for redirect responses the ``Location`` header URL
 will remain relative, and exclude the scheme and domain, by default.
 :pr:`4496`
-   Add ``Config.from_prefixed_env()`` to load config values from
 environment variables that start with ``FLASK_`` or another prefix.
 This parses values as JSON by default, and allows setting keys in
 nested dicts. :pr:`4479`

2.0.3

-------------

Released 2022-02-14

-   The test client's ``as_tuple`` parameter is deprecated and will be
 removed in Werkzeug 2.1. It is now also deprecated in Flask, to be
 removed in Flask 2.1, while remaining compatible with both in
 2.0.x. Use ``response.request.environ`` instead. :pr:`4341`
-   Fix type annotation for ``errorhandler`` decorator. :issue:`4295`
-   Revert a change to the CLI that caused it to hide ``ImportError``
 tracebacks when importing the application. :issue:`4307`
-   ``app.json_encoder`` and ``json_decoder`` are only passed to
 ``dumps`` and ``loads`` if they have custom behavior. This improves
 performance, mainly on PyPy. :issue:`4349`
-   Clearer error message when ``after_this_request`` is used outside a
 request context. :issue:`4333`

2.0.2

-------------

Released 2021-10-04

-   Fix type annotation for ``teardown_*`` methods. :issue:`4093`
-   Fix type annotation for ``before_request`` and ``before_app_request``
 decorators. :issue:`4104`
-   Fixed the issue where typing requires template global
 decorators to accept functions with no arguments. :issue:`4098`
-   Support View and MethodView instances with async handlers. :issue:`4112`
-   Enhance typing of ``app.errorhandler`` decorator. :issue:`4095`
-   Fix registering a blueprint twice with differing names. :issue:`4124`
-   Fix the type of ``static_folder`` to accept ``pathlib.Path``.
 :issue:`4150`
-   ``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``.
 :issue:`4157`
-   Correctly handle raising deferred errors in CLI lazy loading.
 :issue:`4096`
-   The CLI loader handles ``**kwargs`` in a ``create_app`` function.
 :issue:`4170`
-   Fix the order of ``before_request`` and other callbacks that trigger
 before the view returns. They are called from the app down to the
 closest nested blueprint. :issue:`4229`

2.0.1

-------------

Released 2021-05-21

-   Re-add the ``filename`` parameter in ``send_from_directory``. The
 ``filename`` parameter has been renamed to ``path``, the old name
 is deprecated. :pr:`4019`
-   Mark top-level names as exported so type checking understands
 imports in user projects. :issue:`4024`
-   Fix type annotation for ``g`` and inform mypy that it is a namespace
 object that has arbitrary attributes. :issue:`4020`
-   Fix some types that weren't available in Python 3.6.0. :issue:`4040`
-   Improve typing for ``send_file``, ``send_from_directory``, and
 ``get_send_file_max_age``. :issue:`4044`, :pr:`4026`
-   Show an error when a blueprint name contains a dot. The ``.`` has
 special meaning, it is used to separate (nested) blueprint names and
 the endpoint name. :issue:`4041`
-   Combine URL prefixes when nesting blueprints that were created with
 a ``url_prefix`` value. :issue:`4037`
-   Revert a change to the order that URL matching was done. The
 URL is again matched after the session is loaded, so the session is
 available in custom URL converters. :issue:`4053`
-   Re-add deprecated ``Config.from_json``, which was accidentally
 removed early. :issue:`4078`
-   Improve typing for some functions using ``Callable`` in their type
 signatures, focusing on decorator factories. :issue:`4060`
-   Nested blueprints are registered with their dotted name. This allows
 different blueprints with the same name to be nested at different
 locations. :issue:`4069`
-   ``register_blueprint`` takes a ``name`` option to change the
 (pre-dotted) name the blueprint is registered with. This allows the
 same blueprint to be registered multiple times with unique names for
 ``url_for``. Registering the same blueprint with the same name
 multiple times is deprecated. :issue:`1091`
-   Improve typing for ``stream_with_context``. :issue:`4052`

2.0.0

-------------

Released 2021-05-11

-   Drop support for Python 2 and 3.5.
-   Bump minimum versions of other Pallets projects: Werkzeug >= 2,
 Jinja2 >= 3, MarkupSafe >= 2, ItsDangerous >= 2, Click >= 8. Be sure
 to check the change logs for each project. For better compatibility
 with other applications (e.g. Celery) that still require Click 7,
 there is no hard dependency on Click 8 yet, but using Click 7 will
 trigger a DeprecationWarning and Flask 2.1 will depend on Click 8.
-   JSON support no longer uses simplejson. To use another JSON module,
 override ``app.json_encoder`` and ``json_decoder``. :issue:`3555`
-   The ``encoding`` option to JSON functions is deprecated. :pr:`3562`
-   Passing ``script_info`` to app factory functions is deprecated. This
 was not portable outside the ``flask`` command. Use
 ``click.get_current_context().obj`` if it's needed. :issue:`3552`
-   The CLI shows better error messages when the app failed to load
 when looking up commands. :issue:`2741`
-   Add ``SessionInterface.get_cookie_name`` to allow setting the
 session cookie name dynamically. :pr:`3369`
-   Add ``Config.from_file`` to load config using arbitrary file
 loaders, such as ``toml.load`` or ``json.load``.
 ``Config.from_json`` is deprecated in favor of this. :pr:`3398`
-   The ``flask run`` command will only defer errors on reload. Errors
 present during the initial call will cause the server to exit with
 the traceback immediately. :issue:`3431`
-   ``send_file`` raises a ``ValueError`` when passed an ``io`` object
 in text mode. Previously, it would respond with 200 OK and an empty
 file. :issue:`3358`
-   When using ad-hoc certificates, check for the cryptography library
 instead of PyOpenSSL. :pr:`3492`
-   When specifying a factory function with ``FLASK_APP``, keyword
 argument can be passed. :issue:`3553`
-   When loading a ``.env`` or ``.flaskenv`` file, the current working
 directory is no longer changed to the location of the file.
 :pr:`3560`
-   When returning a ``(response, headers)`` tuple from a view, the
 headers replace rather than extend existing headers on the response.
 For example, this allows setting the ``Content-Type`` for
 ``jsonify()``. Use ``response.headers.extend()`` if extending is
 desired. :issue:`3628`
-   The ``Scaffold`` class provides a common API for the ``Flask`` and
 ``Blueprint`` classes. ``Blueprint`` information is stored in
 attributes just like ``Flask``, rather than opaque lambda functions.
 This is intended to improve consistency and maintainability.
 :issue:`3215`
-   Include ``samesite`` and ``secure`` options when removing the
 session cookie. :pr:`3726`
-   Support passing a ``pathlib.Path`` to ``static_folder``. :pr:`3579`
-   ``send_file`` and ``send_from_directory`` are wrappers around the
 implementations in ``werkzeug.utils``. :pr:`3828`
-   Some ``send_file`` parameters have been renamed, the old names are
 deprecated. ``attachment_filename`` is renamed to ``download_name``.
 ``cache_timeout`` is renamed to ``max_age``. ``add_etags`` is
 renamed to ``etag``. :pr:`3828, 3883`
-   ``send_file`` passes ``download_name`` even if
 ``as_attachment=False`` by using ``Content-Disposition: inline``.
 :pr:`3828`
-   ``send_file`` sets ``conditional=True`` and ``max_age=None`` by
 default. ``Cache-Control`` is set to ``no-cache`` if ``max_age`` is
 not set, otherwise ``public``. This tells browsers to validate
 conditional requests instead of using a timed cache. :pr:`3828`
-   ``helpers.safe_join`` is deprecated. Use
 ``werkzeug.utils.safe_join`` instead. :pr:`3828`
-   The request context does route matching before opening the session.
 This could allow a session interface to change behavior based on
 ``request.endpoint``. :issue:`3776`
-   Use Jinja's implementation of the ``|tojson`` filter. :issue:`3881`
-   Add route decorators for common HTTP methods. For example,
 ``app.post("/login")`` is a shortcut for
 ``app.route("/login", methods=["POST"])``. :pr:`3907`
-   Support async views, error handlers, before and after request, and
 teardown functions. :pr:`3412`
-   Support nesting blueprints. :issue:`593, 1548`, :pr:`3923`
-   Set the default encoding to "UTF-8" when loading ``.env`` and
 ``.flaskenv`` files to allow to use non-ASCII characters. :issue:`3931`
-   ``flask shell`` sets up tab and history completion like the default
 ``python`` shell if ``readline`` is installed. :issue:`3941`
-   ``helpers.total_seconds()`` is deprecated. Use
 ``timedelta.total_seconds()`` instead. :pr:`3962`
-   Add type hinting. :pr:`3973`.

1.1.4

-------------

Released 2021-05-13

-   Update ``static_folder`` to use ``_compat.fspath`` instead of
 ``os.fspath`` to continue supporting Python < 3.6 :issue:`4050`

1.1.3

-------------

Released 2021-05-13

-   Set maximum versions of Werkzeug, Jinja, Click, and ItsDangerous.
 :issue:`4043`
-   Re-add support for passing a ``pathlib.Path`` for ``static_folder``.
 :pr:`3579`
Links

Update Flask-Admin from 1.5.7 to 1.6.1.

Changelog

1.6.1

-----

* SQLAlchemy 2.x support
* General updates and bug fixes
* Dropped WTForms 1 support

1.6.0

-----

* Dropped Python 2 support
* WTForms 3.0 support
* Various fixes

1.5.8

-----

* SQLAlchemy 1.4.5+ compatibility fixes
* Redis CLI fixes
Links

Update Flask-SQLAlchemy from 2.4.4 to 3.0.3.

Changelog

3.0.2

-------------

Released 2022-10-14

-   Update compatibility with SQLAlchemy 2. :issue:`1122`

3.0.1

-------------

Released 2022-10-11

-   Export typing information instead of using external typeshed definitions.
 :issue:`1112`
-   If default engine options are set, but ``SQLALCHEMY_DATABASE_URI`` is not set, an
 invalid default bind will not be configured. :issue:`1117`

3.0.0

-------------

Released 2022-10-04

-   Drop support for Python 2, 3.4, 3.5, and 3.6.
-   Bump minimum version of Flask to 2.2.
-   Bump minimum version of SQLAlchemy to 1.4.18.
-   Remove previously deprecated code.
-   The session is scoped to the current app context instead of the thread. This
 requires that an app context is active. This ensures that the session is cleaned up
 after every request.
-   An active Flask application context is always required to access ``session`` and
 ``engine``, regardless of if an application was passed to the constructor.
 :issue:`508, 944`
-   Different bind keys use different SQLAlchemy ``MetaData`` registries, allowing
 tables in different databases to have the same name. Bind keys are stored and looked
 up on the resulting metadata rather than the model or table.
-   ``SQLALCHEMY_DATABASE_URI`` does not default to ``sqlite:///:memory:``. An error is
 raised if neither it nor ``SQLALCHEMY_BINDS`` define any engines. :pr:`731`
-   Configuring SQLite with a relative path is relative to ``app.instance_path`` instead
 of ``app.root_path``. The instance folder is created if necessary. :issue:`462`
-   Added ``get_or_404``, ``first_or_404``, ``one_or_404``, and ``paginate`` methods to
 the extension object. These use SQLAlchemy's preferred ``session.execute(select())``
 pattern instead of the legacy query interface. :issue:`1088`
-   Setup methods that create the engines and session are renamed with a leading
 underscore. They are considered internal interfaces which may change at any time.
-   All parameters to ``SQLAlchemy`` except ``app`` are keyword-only.
-   Renamed the ``bind`` parameter to ``bind_key`` and removed the ``app`` parameter
 from various ``SQLAlchemy`` methods.
-   The extension object uses ``__getattr__`` to alias names from the SQLAlchemy
 package, rather than copying them as attributes.
-   The extension object is stored directly as ``app.extensions["sqlalchemy"]``.
 :issue:`698`
-   The session class can be customized by passing the ``class_`` key in the
 ``session_options`` parameter. :issue:`327`
-   ``SignallingSession`` is renamed to ``Session``.
-   ``Session.get_bind`` more closely matches the base implementation.
-   Model classes and the ``db`` instance are available without imports in
 ``flask shell``. :issue:`1089`
-   The ``CamelCase`` to ``snake_case`` table name converter handles more patterns
 correctly. If model that was already created in the database changed, either use
 Alembic to rename the table, or set ``__tablename__`` to keep the old name.
 :issue:`406`
-   ``Model`` ``repr`` distinguishes between transient and pending instances.
 :issue:`967`
-   A custom model class can implement ``__init_subclass__`` with class parameters.
 :issue:`1002`
-   ``db.Table`` is a subclass instead of a function.
-   The ``engine_options`` parameter is applied as defaults before per-engine
 configuration.
-   ``SQLALCHEMY_BINDS`` values can either be an engine URL, or a dict of engine options
 including URL, for each bind. ``SQLALCHEMY_DATABASE_URI`` and
 ``SQLALCHEMY_ENGINE_OPTIONS`` correspond to the ``None`` key and take precedence.
 :issue:`783`
-   Engines are created when calling ``init_app`` rather than the first time they are
 accessed. :issue:`698`
-   ``db.engines`` exposes the map of bind keys to engines for the current app.
-   ``get_engine``, ``get_tables_for_bind``, and ``get_binds`` are deprecated.
-   SQLite driver-level URIs that look like ``sqlite:///file:name.db?uri=true`` are
 supported. :issue:`998, 1045`
-   SQLite engines do not use ``NullPool`` if ``pool_size`` is 0.
-   MySQL engines use the "utf8mb4" charset by default. :issue:`875`
-   MySQL engines do not set ``pool_size`` to 10.
-   MySQL engines don't set a default for ``pool_recycle`` if not using a queue pool.
 :issue:`803`
-   ``Query`` is renamed from ``BaseQuery``.
-   Added ``Query.one_or_404``.
-   The query class is applied to ``backref`` in ``relationship``. :issue:`417`
-   Creating ``Pagination`` objects manually is no longer a public API. They should be
 created with ``db.paginate`` or ``query.paginate``. :issue:`1088`
-   ``Pagination.iter_pages`` and ``Query.paginate`` parameters are keyword-only.
-   ``Pagination`` is iterable, iterating over its items. :issue:`70`
-   Pagination count query is more efficient.
-   ``Pagination.iter_pages`` is more efficient. :issue:`622`
-   ``Pagination.iter_pages`` ``right_current`` parameter is inclusive.
-   Pagination ``per_page`` cannot be 0. :issue:`1091`
-   Pagination ``max_per_page`` defaults to 100. :issue:`1091`
-   Added ``Pagination.first`` and ``last`` properties, which give the number of the
 first and last item on the page. :issue:`567`
-   ``SQLALCHEMY_RECORD_QUERIES`` is disabled by default, and is not enabled
 automatically with ``app.debug`` or ``app.testing``. :issue:`1092`
-   ``get_debug_queries`` is renamed to ``get_recorded_queries`` to better match the
 config and functionality.
-   Recorded query info is a dataclass instead of a tuple. The ``context`` attribute is
 renamed to ``location``. Finding the location uses a more inclusive check.
-   ``SQLALCHEMY_TRACK_MODIFICATIONS`` is disabled by default. :pr:`727`
-   ``SQLALCHEMY_COMMIT_ON_TEARDOWN`` is deprecated. It can cause various design issues
 that are difficult to debug. Call ``db.session.commit()`` directly instead.
 :issue:`216`

2.5.1

-------------

Released 2021-03-18

-   Fix compatibility with Python 2.7.

2.5.0

-------------

Released 2021-03-18

-   Update to support SQLAlchemy 1.4.
-   SQLAlchemy ``URL`` objects are immutable. Some internal methods have
 changed to return a new URL instead of ``None``. :issue:`885`
Links

Update SQLAlchemy from 1.3.20 to 2.0.5.post1.

Changelog

2.0.5.post1

:released: March 5, 2023

 .. change::
     :tags: bug, orm
     :tickets: 9418

     Added constructor arguments to the built-in mapping collection types
     including :class:`.KeyFuncDict`, :func:`_orm.attribute_keyed_dict`,
     :func:`_orm.column_keyed_dict` so that these dictionary types may be
     constructed in place given the data up front; this provides further
     compatibility with tools such as Python dataclasses ``.asdict()`` which
     relies upon invoking these classes directly as ordinary dictionary classes.

 .. change::
     :tags: bug, orm, regression
     :tickets: 9424

     Fixed multiple regressions due to :ticket:`8372`, involving
     :func:`_orm.attribute_mapped_collection` (now called
     :func:`_orm.attribute_keyed_dict`).

     First, the collection was no longer usable with "key" attributes that were
     not themselves ordinary mapped attributes; attributes linked to descriptors
     and/or association proxy attributes have been fixed.

     Second, if an event or other operation needed access to the "key" in order
     to populate the dictionary from an mapped attribute that was not
     loaded, this also would raise an error inappropriately, rather than
     trying to load the attribute as was the behavior in 1.4.  This is also
     fixed.

     For both cases, the behavior of :ticket:`8372` has been expanded.
     :ticket:`8372` introduced an error that raises when the derived key that
     would be used as a mapped dictionary key is effectively unassigned. In this
     change, a warning only is emitted if the effective value of the ".key"
     attribute is ``None``, where it cannot be unambiguously determined if this
     ``None`` was intentional or not. ``None`` will be not supported as mapped
     collection dictionary keys going forward (as it typically refers to NULL
     which means "unknown"). Setting
     :paramref:`_orm.attribute_keyed_dict.ignore_unpopulated_attribute` will now
     cause such ``None`` keys to be ignored as well.

 .. change::
     :tags: engine, performance
     :tickets: 9343

     A small optimization to the Cython implementation of :class:`.Result`
     using a cdef for a particular int value to avoid Python overhead. Pull
     request courtesy Matus Valo.


 .. change::
     :tags: bug, mssql
     :tickets: 9414

     Fixed issue in the new :class:`.Uuid` datatype which prevented it from
     working with the pymssql driver. As pymssql seems to be maintained again,
     restored testing support for pymssql.

 .. change::
     :tags: bug, mssql

     Tweaked the pymssql dialect to take better advantage of
     RETURNING for INSERT statements in order to retrieve last inserted primary
     key values, in the same way as occurs for the mssql+pyodbc dialect right
     now.

 .. change::
     :tags: bug, orm

     Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now
     compatible with the SQLAlchemy ORM's "versioned rows" feature, since
     SQLAlchemy now computes rowcount for a RETURNING statement in this specific
     case by counting the rows returned, rather than relying upon
     ``cursor.rowcount``.  In particular, the ORM versioned rows use case
     (documented at :ref:`mapper_version_counter`) should now be fully
     supported with the SQL Server pyodbc dialect.


 .. change::
     :tags: bug, postgresql
     :tickets: 9349

     Fixed issue in PostgreSQL :class:`_postgresql.ExcludeConstraint` where
     literal values were being compiled as bound parameters and not direct
     inline values as is required for DDL.

 .. change::
     :tags: bug, typing

     Fixed bug where the :meth:`_engine.Connection.scalars` method was not typed
     as allowing a multiple-parameters list, which is now supported using
     insertmanyvalues operations.

 .. change::
     :tags: bug, typing
     :tickets: 9376

     Improved typing for the mapping passed to :meth:`.Insert.values` and
     :meth:`.Update.values` to be more open-ended about collection type, by
     indicating read-only ``Mapping`` instead of writeable ``Dict`` which would
     error out on too limited of a key type.

 .. change::
     :tags: schema

     Validate that when provided the :paramref:`_schema.MetaData.schema`
     argument of :class:`_schema.MetaData` is a string.

 .. change::
     :tags: typing, usecase
     :tickets: 9338

     Exported the type returned by
     :meth:`_orm.scoped_session.query_property` using a new public type
     :class:`.orm.QueryPropertyDescriptor`.

 .. change::
     :tags: bug, mysql, postgresql
     :tickets: 5648

     The support for pool ping listeners to receive exception events via the
     :meth:`.DialectEvents.handle_error` event added in 2.0.0b1 for
     :ticket:`5648` failed to take into account dialect-specific ping routines
     such as that of MySQL and PostgreSQL. The dialect feature has been reworked
     so that all dialects participate within event handling.   Additionally,
     a new boolean element :attr:`.ExceptionContext.is_pre_ping` is added
     which identifies if this operation is occurring within the pre-ping
     operation.

     For this release, third party dialects which implement a custom
     :meth:`_engine.Dialect.do_ping` method can opt in to the newly improved
     behavior by having their method no longer catch exceptions or check
     exceptions for "is_disconnect", instead just propagating all exceptions
     outwards. Checking the exception for "is_disconnect" is now done by an
     enclosing method on the default dialect, which ensures that the event hook
     is invoked for all exception scenarios before testing the exception as a
     "disconnect" exception. If an existing ``do_ping()`` method continues to
     catch exceptions and check "is_disconnect", it will continue to work as it
     did previously, but ``handle_error`` hooks will not have access to the
     exception if it isn't propagated outwards.

 .. change::
     :tags: bug, ext
     :tickets: 9367

     Fixed issue in automap where calling :meth:`_automap.AutomapBase.prepare`
     from a specific mapped class, rather than from the
     :class:`_automap.AutomapBase` directly, would not use the correct base
     class when automap detected new tables, instead using the given class,
     leading to mappers trying to configure inheritance. While one should
     normally call :meth:`_automap.AutomapBase.prepare` from the base in any
     case, it shouldn't misbehave that badly when called from a subclass.


 .. change::
     :tags: bug, sqlite, regression
     :tickets: 9379

     Fixed regression for SQLite connections where use of the ``deterministic``
     parameter when establishing database functions would fail for older SQLite
     versions, those prior to version 3.8.3. The version checking logic has been
     improved to accommodate for this case.

 .. change::
     :tags: bug, typing
     :tickets: 9391

     Added missing init overload to the :class:`_types.Numeric` type object so
     that pep-484 type checkers may properly resolve the complete type, deriving
     from the :paramref:`_types.Numeric.asdecimal` parameter whether ``Decimal``
     or ``float`` objects will be represented.

 .. change::
     :tags: bug, typing
     :tickets: 9398

     Fixed typing bug where :meth:`_sql.Select.from_statement` would not accept
     :func:`_sql.text` or :class:`.TextualSelect` objects as a valid type.
     Additionally repaired the :class:`.TextClause.columns` method to have a
     return type, which was missing.

 .. change::
     :tags: bug, orm declarative
     :tickets: 9332

     Fixed issue where new :paramref:`_orm.mapped_column.use_existing_column`
     feature would not work if the two same-named columns were mapped under
     attribute names that were differently-named from an explicit name given to
     the column itself. The attribute names can now be differently named when
     using this parameter.

 .. change::
     :tags: bug, orm
     :tickets: 9373

     Added support for the :paramref:`_orm.Mapper.polymorphic_load` parameter to
     be applied to each mapper in an inheritance hierarchy more than one level
     deep, allowing columns to load for all classes in the hierarchy that
     indicate ``"selectin"`` using a single statement, rather than ignoring
     elements on those intermediary classes that nonetheless indicate they also
     would participate in ``"selectin"`` loading and were not part of the
     base-most SELECT statement.

 .. change::
     :tags: bug, orm
     :tickets: 8853, 9335

     Continued the fix for :ticket:`8853`, allowing the :class:`_orm.Mapped`
     name to be fully qualified regardless of whether or not
     ``from __annotations__ import future`` were present. This issue first fixed
     in 2.0.0b3 confirmed that this case worked via the test suite, however the
     test suite apparently was not testing the behavior for the name
     :class:`_orm.Mapped` not being locally present at all; string resolution
     has been updated to ensure the :class:`_orm.Mapped` symbol is locatable as
     applies to how the ORM uses these functions.

 .. change::
     :tags: bug, typing
     :tickets: 9340

     Fixed typing issue where :func:`_orm.with_polymorphic` would not
     record the class type correctly.

 .. change::
     :tags: bug, ext, regression
     :tickets: 9380

     Fixed regression caused by typing added to ``sqlalchemy.ext.mutable`` for
     :ticket:`8667`, where the semantics of the ``.pop()`` method changed such
     that the method was non-working. Pull request courtesy Nils Philippsen.

 .. change::
     :tags: bug, sql, regression
     :tickets: 9390

     Restore the :func:`.nullslast` and :func:`.nullsfirst` legacy functions
     into the ``sqlalchemy`` import namespace. Previously, the newer
     :func:`.nulls_last` and :func:`.nulls_first` functions were available, but
     the legacy ones were inadvertently removed.

 .. change::
     :tags: bug, postgresql
     :tickets: 9401

     Fixed issue where the PostgreSQL :class:`_postgresql.ExcludeConstraint`
     construct would not be copyable within operations such as
     :meth:`_schema.Table.to_metadata` as well as within some Alembic scenarios,
     if the constraint contained textual expression elements.

 .. change::
     :tags: bug, engine
     :tickets: 9423

     Fixed bug where :class:`_engine.Row` objects could not be reliably unpickled
     across processes due to an accidental reliance on an unstable hash value.

.. changelog::

2.0.4

:released: February 17, 2023

 .. change::
     :tags: bug, orm, regression
     :tickets: 9273

     Fixed regression introduced in version 2.0.2 due to :ticket:`9217` where
     using DML RETURNING statements, as well as
     :meth:`_sql.Select.from_statement` constructs as was "fixed" in
     :ticket:`9217`, in conjunction with ORM mapped classes that used
     expressions such as with :func:`_orm.column_property`, would lead to an
     internal error within Core where it would attempt to match the expression
     by name. The fix repairs the Core issue, and also adjusts the fix in
     :ticket:`9217` to not take effect for the DML RETURNING use case, where it
     adds unnecessary overhead.

 .. change::
     :tags: usecase, typing
     :tickets: 9321

     Improved the typing support for the :ref:`hybrids_toplevel`
     extension, updated all documentation to use ORM Annotated Declarative
     mappings, and added a new modifier called :attr:`.hybrid_property.inplace`.
     This modifier provides a way to alter the state of a :class:`.hybrid_property`
     **in place**, which is essentially what very early versions of hybrids
     did, before SQLAlchemy version 1.2.0 :ticket:`3912` changed this to
     remove in-place mutation.  This in-place mutation is now restored on an
     **opt-in** basis to allow a single hybrid to have multiple methods
     set up, without the need to name all the methods the same and without the
     need to carefully "chain" differently-named methods in order to maintain
     the composition.  Typing tools such as Mypy and Pyright do not allow
     same-named methods on a class, so with this change a succinct method
     of setting up hybrids with typing support is restored.

     .. seealso::

         :ref:`hybrid_pep484_naming`

 .. change::
     :tags: bug, orm

     Marked the internal ``EvaluatorCompiler`` module as private to the ORM, and
     renamed it to ``_EvaluatorCompiler``. For users that may have been relying
     upon this, the name ``EvaluatorCompiler`` is still present, however this
     use is not supported and will be removed in a future release.

 .. change::
     :tags: orm, use_case
     :tickets: 9297

     To accommodate a change in column ordering used by ORM Declarative in
     SQLAlchemy 2.0, a new parameter :paramref:`_orm.mapped_column.sort_order`
     has been added that can be used to control the order of the columns defined
     in the table by the ORM, for common use cases such as mixins with primary
     key columns that should appear first in tables. The change notes at
     :ref:`change_9297` illustrate the default change in ordering behavior
     (which is part of all SQLAlchemy 2.0 releases) as well as use of the
     :paramref:`_orm.mapped_column.sort_order` to control column ordering when
     using mixins and multiple classes (new in 2.0.4).

     .. seealso::

         :ref:`change_9297`

 .. change::
     :tags: sql
     :tickets: 9277

     Added public property :attr:`_schema.Table.autoincrement_column` that
     returns the column identified as autoincrementing in the column.

 .. change::
     :tags: oracle, bug
     :tickets: 9295

     Adjusted the behavior of the ``thick_mode`` parameter for the
     :ref:`oracledb` dialect to correctly accept ``False`` as a value.
     Previously, only ``None`` would indicate that thick mode should be
     disabled.

 .. change::
     :tags: usecase, orm
     :tickets: 9298

     The :meth:`_orm.Session.refresh` method will now immediately load a
     relationship-bound attribute that is explicitly named within the
     :paramref:`_orm.Session.refresh.attribute_names` collection even if it is
     currently linked to the "select" loader, which normally is a "lazy" loader
     that does not fire off during a refresh. The "lazy loader" strategy will
     now detect that the operation is specifically a user-initiated
     :meth:`_orm.Session.refresh` operation which named this attribute
     explicitly, and will then call upon the "immediateload" strategy to
     actually emit SQL to load the attribute. This should be helpful in
     particular for some asyncio situations where the loading of an unloaded
     lazy-loaded attribute must be forced, without using the actual lazy-loading
     attribute pattern not supported in asyncio.


 .. change::
     :tags: bug, sql
     :tickets: 9313

     Fixed issue where element types of a tuple value would be hardcoded to take
     on the types from a compared-to tuple, when the comparison were using the
     :meth:`.ColumnOperators.in_` operator. This was inconsistent with the usual
     way that types are determined for a binary expression, which is that the
     actual element type on the right side is considered first before applying
     the left-hand-side type.

 .. change::
     :tags: usecase, orm declarative
     :tickets: 9266

     Added new parameter ``dataclasses_callable`` to both the
     :class:`_orm.MappedAsDataclass` class as well as the
     :meth:`_orm.registry.mapped_as_dataclass` method which allows an
     alternative callable to Python ``dataclasses.dataclass`` to be used in
     order to produce dataclasses. The use case here is to drop in Pydantic's
     dataclass function instead. Adjustments have been made to the mixin support
     added for :ticket:`9179` in version 2.0.1 so that the ``__annotations__``
     collection of the mixin is rewritten to not include the
     :class:`_orm.Mapped` container, in the same way as occurs with mapped
     classes, so that the Pydantic dataclasses constructor is not exposed to
     unknown types.

     .. seealso::

         :ref:`dataclasses_pydantic`


.. changelog::

2.0.3

:released: February 9, 2023

 .. change::
     :tags: typing, bug
     :tickets: 9254

     Remove ``typing.Self`` workaround, now using :pep:`673` for most methods
     that return ``Self``. As a consequence of this change ``mypy>=1.0.0`` is
     now required to type check SQLAlchemy code.
     Pull request courtesy Yurii Karabas.

 .. change::
     :tags: bug, sql, regression
     :tickets: 9271

     Fixed critical regression in SQL expression formulation in the 2.0 series
     due to :ticket:`7744` which improved support for SQL expressions that
     contained many elements against the same operator repeatedly; parenthesis
     grouping would be lost with expression elements beyond the first two
     elements.


.. changelog::

2.0.2

:released: February 6, 2023

 .. change::
     :tags: bug, orm declarative
     :tickets: 9249

     Fixed regression caused by the fix for :ticket:`9171`, which itself was
     fixing a regression, involving the mechanics of ``__init__()`` on classes
     that extend from :class:`_orm.DeclarativeBase`. The change made it such
     that ``__init__()`` was applied to the user-defined base if there were no
     ``__init__()`` method directly on the class. This has been adjusted so that
     ``__init__()`` is applied only if no other class in the hierarchy of the
     user-defined base has an ``__init__()`` method. This again allows
     user-defined base classes based on :class:`_orm.DeclarativeBase` to include
     mixins that themselves include a custom ``__init__()`` method.

 .. change::
     :tags: bug, mysql, regression
     :tickets: 9251

     Fixed regression caused by issue :ticket:`9058` which adjusted the MySQL
     dialect's ``has_table()`` to again use "DESCRIBE", where the specific error
     code raised by MySQL version 8 when using a non-existent schema name was
     unexpected and failed to be interpreted as a boolean result.



 .. change::
     :tags: bug, sqlite
     :tickets: 9251

     Fixed the SQLite dialect's ``has_table()`` function to correctly report
     False for queries that include a non-None schema name for a schema that
     doesn't exist; previously, a database error was raised.


 .. change::
     :tags: bug, orm declarative
     :tickets: 9226

     Fixed issue in ORM Declarative Dataclass mappings related to newly added
     support for mixins added in 2.0.1 via :ticket:`9179`, where a combination
     of using mixins plus ORM inheritance would mis-classify fields in some
     cases leading to field-level dataclass arguments such as ``init=False`` being
     lost.

 .. change::
     :tags: bug, orm, ression
     :tickets: 9232

     Fixed obscure ORM inheritance issue caused by :ticket:`8705` where some
     scenarios of inheriting mappers that indicated groups of columns from the
     local table and the inheriting table together under a
     :func:`_orm.column_property` would nonetheless warn that properties of the
     same name were being combined implicitly.

 .. change::
     :tags: orm, bug, regression
     :tickets: 9228

     Fixed regression where using the :paramref:`_orm.Mapper.version_id_col`
     feature with a regular Python-side incrementing column would fail to work
     for SQLite and other databases that don't support "rowcount" with
     "RETURNING", as "RETURNING" would be assumed for such columns even though
     that's not what actually takes place.

 .. change::
     :tags: bug, orm declarative
     :tickets: 9240

     Repaired ORM Declarative mappings to allow for the
     :paramref:`_orm.Mapper.primary_key` parameter to be specified within
     ``__mapper_args__`` when using :func:`_orm.mapped_column`. Despite this
     usage being directly in the 2.0 documentation, the :class:`_orm.Mapper` was
     not accepting the :func:`_orm.mapped_column` construct in this context. Ths
     feature was already working for the :paramref:`_orm.Mapper.version_id_col`
     and :paramref:`_orm.Mapper.polymorphic_on` parameters.

     As part of this change, the ``__mapper_args__`` attribute may be specified
     without using :func:`_orm.declared_attr` on a non-mapped mixin class,
     including a ``"primary_key"`` entry that refers to :class:`_schema.Column`
     or :func:`_orm.mapped_column` objects locally present on the mixin;
     Declarative will also translate these columns into the correct ones for a
     particular mapped class. This again was working already for the
     :paramref:`_orm.Mapper.version_id_col` and
     :paramref:`_orm.Mapper.polymorphic_on` parameters.  Additionally,
     elements within ``"primary_key"`` may be indicated as string names of
     existing mapped properties.

 .. change::
     :tags: usecase, sql
     :tickets: 8780

     Added a full suite of new SQL bitwise operators, for performing
     database-side bitwise expressions on appropriate data values such as
     integers, bit-strings, and similar. Pull request courtesy Yegor Statkevich.

     .. seealso::

         :ref:`operators_bitwise`


 .. change::
     :tags: bug, orm declarative
     :tickets: 9211

     An explicit error is raised if a mapping attempts to mix the use of
     :class:`_orm.MappedAsDataclass` with
     :meth:`_orm.registry.mapped_as_dataclass` within the same class hierarchy,
     as this produces issues with the dataclass function being applied at the
     wrong time to the mapped class, leading to errors during the mapping
     process.

 .. change::
     :tags: bug, orm, regression
     :tickets: 9217

     Fixed regression when using :meth:`_sql.Select.from_statement` in an ORM
     context, where matching of columns to SQL labels based on name alone was
     disabled for ORM-statements that weren't fully textual. This would prevent
     arbitrary SQL expressions with column-name labels from matching up to the
     entity to be loaded, which previously would work within the 1.4
     and previous series, so the previous behavior has been restored.

 .. change::
     :tags: bug, asyncio
     :tickets: 9237

     Repaired a regression caused by the fix for :ticket:`8419` which caused
     asyncpg connections to be reset (i.e. transaction ``rollback()`` called)
     and returned to the pool normally in the case that the connection were not
     explicitly returned to the connection pool and was instead being
     intercepted by Python garbage collection, which would fail if the garbage
     collection operation were being called outside of the asyncio event loop,
     leading to a large amount of stack trace activity dumped into logging
     and standard output.

     The correct behavior is restored, which is that all asyncio connections
     that are garbage collected due to not being explicitly returned to the
     connection pool are detached from the pool and discarded, along with a
     warning, rather than being returned the pool, as they cannot be reliably
     reset. In the case of asyncpg connections, the asyncpg-specific
     ``terminate()`` method will be used to end the connection more gracefully
     within this process as opposed to just dropping it.

     This change includes a small behavioral change that is hoped to be useful
     for debugging asyncio applications, where the warning that's emitted in the
     case of asyncio connections being unexpectedly garbage collected has been
     made slightly more aggressive by moving it outside of a ``try/except``
     block and into a ``finally:`` block, where it will emit unconditionally
     regardless of whether the detach/termination operation succeeded or not. It
     will also have the effect that applications or test suites which promote
     Python warnings to exceptions will see this as a full exception raise,
     whereas previously it was not possible for this warning to actually
     propagate as an exception. Applications and test suites which need to
     tolerate this warning in the interim should adjust the Python warnings
     filter to allow these warnings to not raise.

     The behavior for traditional sync connections remains unchanged, that
     garbage collected connections continue to be returned to the pool normally
     without emitting a warning. This will likely be changed in a future major
     release to at least emit a similar warning as is emitted for asyncio
     drivers, as it is a usage error for pooled connections to be intercepted by
     garbage collection without being properly returned to the pool.

 .. change::
     :tags: usecase, orm
     :tickets: 9220

     Added new event hook :meth:`_orm.MapperEvents.after_mapper_constructed`,
     which supplies an event hook to take place right as the
     :class:`_orm.Mapper` object has been fully constructed, but before the
     :meth:`_orm.registry.configure` call has been called. This allows code that
     can create additional mappings and table structures based on the initial
     configuration of a :class:`_orm.Mapper`, which also integrates within
     Declarative configuration. Previously, when using Declarative, where the
     :class:`_orm.Mapper` object is created within the class creation process,
     there was no documented means of running code at this point.  The change
     is to immediately benefit custom mapping schemes such as that
     of the :ref:`examples_versioned_history` example, which generate additional
     mappers and tables in response to the creation of mapped classes.


 .. change::
     :tags: usecase, orm
     :tickets: 9220

     The infrequently used :attr:`_orm.Mapper.iterate_properties` attribute and
     :meth:`_orm.Mapper.get_property` method, which are primarily used
     internally, no longer implicitly invoke the :meth:`_orm.registry.configure`
     process. Public access to these methods is extremely rare and the only
     benefit to having :meth:`_orm.registry.configure` would have been allowing
     "backref" properties be present in these collections. In order to support
     the new :meth:`_orm.MapperEvents.after_mapper_constructed` event, iteration
     and access to the internal :class:`_orm.MapperProperty` objects is now
     possible without triggering an implicit configure of the mapper itself.

     The more-public facing route to iteration of all mapper attributes, the
     :attr:`_orm.Mapper.attrs` collection and similar, will still implicitly
     invoke the :meth:`_orm.registry.configure` step thus making backref
     attributes available.

     In all cases, the :meth:`_orm.registry.configure` is always available to
     be called directly.

 .. change::
     :tags: bug, examples
     :tickets: 9220

     Reworked the :ref:`examples_versioned_history` to work with
     version 2.0, while at the same time improving the overall working of
     this example to use newer APIs, including a newly added hook
     :meth:`_orm.MapperEvents.after_mapper_constructed`.



 .. change::
     :tags: bug, mysql
     :tickets: 8626

     Added support for MySQL 8's new ``AS <name> ON DUPLICATE KEY`` syntax when
     using :meth:`_mysql.Insert.on_duplicate_key_update`, which is required for
     newer versions of MySQL 8 as the previous syntax using ``VALUES()`` now
     emits a deprecation warning with those versions. Server version detection
     is employed to determine if traditional MariaDB / MySQL < 8 ``VALUES()``
     syntax should be used, vs. the newer MySQL 8 required syntax. Pull request
     courtesy Caspar Wylie.

.. changelog::

2.0.1

:released: February 1, 2023

 .. change::
     :tags: bug, typing
     :tickets: 9174

     Opened up typing on :paramref:`.Select.with_for_update.of` to also accept
     table and mapped class arguments, as seems to be available for the MySQL
     dialect.

 .. change::
     :tags: bug, orm, regression
     :tickets: 9164

     Fixed regression where ORM models that used joined table inheritance with a
     composite foreign key would encounter an internal error in the mapper
     internals.



 .. change::
     :tags: bug, sql
     :tickets: 7664

     Corrected the fix for :ticket:`7664`, released in version 2.0.0, to also
     include :class:`.DropSchema` which was inadvertently missed in this fix,
     allowing stringification without a dialect. The fixes for both constructs
     is backported to the 1.4 series as of 1.4.47.


 .. change::
     :tags: bug, orm declarative
     :tickets: 9175

     Added support for :pep:`484` ``NewType`` to be used in the
     :paramref:`_orm.registry.type_annotation_map` as well as within
     :class:`.Mapped` constructs. These types will behave in the same way as
     custom subclasses of types right now; they must appear explicitly within
     the :paramref:`_orm.registry.type_annotation_map` to be mapped.

 .. change::
     :tags: bug, typing
     :tickets: 9183

     Fixed typing for limit/offset methods including :meth:`.Select.limit`,
     :meth:`.Select.offset`, :meth:`_orm.Query.limit`, :meth:`_orm.Query.offset`
     to allow ``None``, which is the documented API to "cancel" the current
     limit/offset.



 .. change::
     :tags: bug, orm declarative
     :tickets: 9179

     When using the :class:`.MappedAsDataclass` superclass, all classes within
     the hierarchy that are subclasses of this class will now be run through the
     ``dataclasses.dataclass`` function whether or not they are actually
     mapped, so that non-ORM fields declared on non-mapped classes within the
     hierarchy will be used when mapped subclasses are turned into dataclasses.
     This behavior applies both to intermediary classes mapped with
     ``__abstract__ = True`` as well as to the user-defined declarative base
     itself, assuming :class:`.MappedAsDataclass` is present as a superclass for
     these classes.

     This allows non-mapped attributes such as ``InitVar`` declarations on
     superclasses to be used, without the need to run the
     ``dataclasses.dataclass`` decorator explicitly on each non-mapped class.
     The new behavior is considered as correct as this is what the :pep:`681`
     implementation expects when using a superclass to indicate dataclass
     behavior.

 .. change::
     :tags: bug, typing
     :tickets: 9170

     Fixed typing issue where :func:`_orm.mapped_column` objects typed as
     :class:`_orm.Mapped` wouldn't be accepted in schema constraints such as
     :class:`_schema.ForeignKey`, :class:`_schema.UniqueConstraint` or
     :class:`_schema.Index`.

 .. change::
     :tags: bug, orm declarative
     :tickets: 9187

     Added support for :pep:`586` ``Literal[]`` to be used in the
     :paramref:`_orm.registry.type_annotation_map` as well as within
     :class:`.Mapped` constructs. To use custom types such as these, they must
     appear explicitly within the :paramref:`_orm.registry.type_annotation_map`
     to be mapped.  Pull request courtesy Frederik Aalund.

     As part of this change, the support for :class:`.sqltypes.Enum` in the
     :paramref:`_orm.registry.type_annotation_map` has been expanded to include
     support for ``Literal[]`` types consisting of string values to be used,
     in addition to ``enum.Enum`` datatypes.    If a ``Literal[]`` datatype
     is used within ``Mapped[]`` that is not linked in
     :paramref:`_orm.registry.type_annotation_map` to a specific datatype,
     a :class:`.sqltypes.Enum` will be used by default.

     .. seealso::

         :ref:`orm_declarative_mapped_column_enums`


 .. change::
     :tags: bug, orm declarative
     :tickets: 9200

     Fixed issue involving the use of :class:`.sqltypes.Enum` within the
     :paramref:`_orm.registry.type_annotation_map` where the
     :paramref:`_sqltypes.Enum.native_enum` parameter would not be correctly
     copied to the mapped column datatype, if it were overridden
     as stated in the documentation to set this parameter to False.



 .. change::
     :tags: bug, orm declarative, regression
     :tickets: 9171

     Fixed regression in :class:`.DeclarativeBase` class where the registry's
     default constructor would not be applied to the base itself, which is
     different from how the previous :func:`_orm.declarative_base` construct
     works. This would prevent a mapped class with its own ``__init__()`` method
     from calling ``super().__init__()`` in order to access the registry's
     default constructor and automatically populate attributes, instead hitting
     ``object.__init__()`` which would raise a ``TypeError`` on any arguments.




 .. change::
     :tags: bug, sql, regression
     :tickets: 9173

     Fixed regression related to the implementation for the new
     "insertmanyvalues" feature where an internal ``TypeError`` would occur in
     arrangements where a :func:`_sql.insert` would be referred towards inside
     of another :func:`_sql.insert` via a CTE; made additional repairs for this
     use case for positional dialects such as asyncpg when using
     "insertmanyvalues".



 .. change::
     :tags: bug, typing
     :tickets: 9156

     Fixed typing for :meth:`_expression.ColumnElement.cast` to accept
     both ``Type[TypeEngine[T]]`` and ``TypeEngine[T]``; previously
     only ``TypeEngine[T]`` was accepted.  Pull request courtesy Yurii Karabas.

 .. change::
     :tags: bug, orm declarative
     :tickets: 9177

     Improved the ruleset used to interpret :pep:`593` ``Annotated`` types when
     used with Annotated Declarative mapping, the inner type will be checked for
     "Optional" in all cases which will be added to the criteria by which the
     column is set as "nullable" or not; if the type within the ``Annotated``
     container is optional (or unioned with ``None``), the column will be
     considered nullable if there are no explicit
     :paramref:`_orm.mapped_column.nullable` parameters overriding it.

 .. change::
     :tags: bug, orm
     :tickets: 9182

     Improved the error reporting when linking strategy options from a base
     class to another attribute that's off a subclass, where ``of_type()``
     should be used. Previously, when :meth:`.Load.options` is used, the message
     would lack informative detail that ``of_type()`` should be used, which was
     not the case when linking the options directly. The informative detail now
     emits even if :meth:`.Load.options` is used.



.. changelog::

2.0.0

:released: January 26, 2023

 .. change::
     :tags: bug, sql
     :tickets: 7664

     Fixed stringify for a the :class:`.CreateSchema` DDL construct, which
     would fail with an ``AttributeError`` when stringified without a
     dialect. Update: Note this fix failed to accommodate for
     :class:`.DropSchema`; a followup fix in version 2.0.1 repairs this
     case. The fix for both elements is backported to 1.4.47.

 .. change::
     :tags: usecase, orm extensions
     :tickets: 5145

     Added new feature to :class:`.AutomapBase` for autoload of classes across
     multiple schemas which may have overlapping names, by providing a
     :paramref:`.AutomapBase.prepare.modulename_for_table` parameter which
     allows customization of the ``__module__`` attribute of newly generated
     classes, as well as a new collection :attr:`.AutomapBase.by_module`, which
     stores a dot-separated namespace of module names linked to class

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/jeffknupp/sandman2/pull/315 **Author:** [@pyup-bot](https://github.com/pyup-bot) **Created:** 3/13/2023 **Status:** ❌ Closed **Base:** `master` ← **Head:** `pyup-scheduled-update-2023-03-13` --- ### 📝 Commits (10+) - [`4c58141`](https://github.com/jeffknupp/sandman2/commit/4c581419f9faa58fa9202b5b0e92f3f7d30e1306) Update flask from 1.1.2 to 2.2.3 - [`7be1e2e`](https://github.com/jeffknupp/sandman2/commit/7be1e2e4f4c9b548e6544cfe175f62c9b934951a) Update flask-admin from 1.5.7 to 1.6.1 - [`5b1d1df`](https://github.com/jeffknupp/sandman2/commit/5b1d1df024ea1763be42759bc8cc1a5f3f6df581) Update flask-sqlalchemy from 2.4.4 to 3.0.3 - [`510f15b`](https://github.com/jeffknupp/sandman2/commit/510f15bbd60c6ed66163a2fad9c8df3113b0ed06) Update sqlalchemy from 1.3.20 to 2.0.5.post1 - [`96effcc`](https://github.com/jeffknupp/sandman2/commit/96effcc7bcec0a2d82ac2683d0003b098faccf60) Update wtforms from 2.3.3 to 3.0.1 - [`97a15f7`](https://github.com/jeffknupp/sandman2/commit/97a15f71ae866812d5471ba4a261c3feaca4ccea) Update coverage from 5.3 to 7.2.1 - [`c97dbcd`](https://github.com/jeffknupp/sandman2/commit/c97dbcdb8ab02682289afb390e91b09fdd260dd6) Update pytest from 6.2.0 to 7.2.2 - [`201e3ec`](https://github.com/jeffknupp/sandman2/commit/201e3eccca39c136e99430d7dbf46f4329b58269) Update flask-cors from 3.0.9 to 3.0.10 - [`0d82d19`](https://github.com/jeffknupp/sandman2/commit/0d82d192b1bc9cf00d9e96bb89c82a4bc1b2539c) Update pytest-cov from 2.10.1 to 4.0.0 - [`c9e9f75`](https://github.com/jeffknupp/sandman2/commit/c9e9f750abaa660290784a3066c4ac763294c53a) Update pytest-flask from 1.1.0 to 1.2.0 ### 📊 Changes **1 file changed** (+15 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `requirements.txt` (+15 -15) </details> ### 📄 Description ### Update [Flask](https://pypi.org/project/Flask) from **1.1.2** to **2.2.3**. <details> <summary>Changelog</summary> ### 2.2.3 ``` ------------- Released 2023-02-15 - Autoescape is enabled by default for ``.svg`` template files. :issue:`4831` - Fix the type of ``template_folder`` to accept ``pathlib.Path``. :issue:`4892` - Add ``--debug`` option to the ``flask run`` command. :issue:`4777` ``` ### 2.2.2 ``` ------------- Released 2022-08-08 - Update Werkzeug dependency to &gt;= 2.2.2. This includes fixes related to the new faster router, header parsing, and the development server. :pr:`4754` - Fix the default value for ``app.env`` to be ``&quot;production&quot;``. This attribute remains deprecated. :issue:`4740` ``` ### 2.2.1 ``` ------------- Released 2022-08-03 - Setting or accessing ``json_encoder`` or ``json_decoder`` raises a deprecation warning. :issue:`4732` ``` ### 2.2.0 ``` ------------- Released 2022-08-01 - Remove previously deprecated code. :pr:`4667` - Old names for some ``send_file`` parameters have been removed. ``download_name`` replaces ``attachment_filename``, ``max_age`` replaces ``cache_timeout``, and ``etag`` replaces ``add_etags``. Additionally, ``path`` replaces ``filename`` in ``send_from_directory``. - The ``RequestContext.g`` property returning ``AppContext.g`` is removed. - Update Werkzeug dependency to &gt;= 2.2. - The app and request contexts are managed using Python context vars directly rather than Werkzeug&#x27;s ``LocalStack``. This should result in better performance and memory use. :pr:`4682` - Extension maintainers, be aware that ``_app_ctx_stack.top`` and ``_request_ctx_stack.top`` are deprecated. Store data on ``g`` instead using a unique prefix, like ``g._extension_name_attr``. - The ``FLASK_ENV`` environment variable and ``app.env`` attribute are deprecated, removing the distinction between development and debug mode. Debug mode should be controlled directly using the ``--debug`` option or ``app.run(debug=True)``. :issue:`4714` - Some attributes that proxied config keys on ``app`` are deprecated: ``session_cookie_name``, ``send_file_max_age_default``, ``use_x_sendfile``, ``propagate_exceptions``, and ``templates_auto_reload``. Use the relevant config keys instead. :issue:`4716` - Add new customization points to the ``Flask`` app object for many previously global behaviors. - ``flask.url_for`` will call ``app.url_for``. :issue:`4568` - ``flask.abort`` will call ``app.aborter``. ``Flask.aborter_class`` and ``Flask.make_aborter`` can be used to customize this aborter. :issue:`4567` - ``flask.redirect`` will call ``app.redirect``. :issue:`4569` - ``flask.json`` is an instance of ``JSONProvider``. A different provider can be set to use a different JSON library. ``flask.jsonify`` will call ``app.json.response``, other functions in ``flask.json`` will call corresponding functions in ``app.json``. :pr:`4692` - JSON configuration is moved to attributes on the default ``app.json`` provider. ``JSON_AS_ASCII``, ``JSON_SORT_KEYS``, ``JSONIFY_MIMETYPE``, and ``JSONIFY_PRETTYPRINT_REGULAR`` are deprecated. :pr:`4692` - Setting custom ``json_encoder`` and ``json_decoder`` classes on the app or a blueprint, and the corresponding ``json.JSONEncoder`` and ``JSONDecoder`` classes, are deprecated. JSON behavior can now be overridden using the ``app.json`` provider interface. :pr:`4692` - ``json.htmlsafe_dumps`` and ``json.htmlsafe_dump`` are deprecated, the function is built-in to Jinja now. :pr:`4692` - Refactor ``register_error_handler`` to consolidate error checking. Rewrite some error messages to be more consistent. :issue:`4559` - Use Blueprint decorators and functions intended for setup after registering the blueprint will show a warning. In the next version, this will become an error just like the application setup methods. :issue:`4571` - ``before_first_request`` is deprecated. Run setup code when creating the application instead. :issue:`4605` - Added the ``View.init_every_request`` class attribute. If a view subclass sets this to ``False``, the view will not create a new instance on every request. :issue:`2520`. - A ``flask.cli.FlaskGroup`` Click group can be nested as a sub-command in a custom CLI. :issue:`3263` - Add ``--app`` and ``--debug`` options to the ``flask`` CLI, instead of requiring that they are set through environment variables. :issue:`2836` - Add ``--env-file`` option to the ``flask`` CLI. This allows specifying a dotenv file to load in addition to ``.env`` and ``.flaskenv``. :issue:`3108` - It is no longer required to decorate custom CLI commands on ``app.cli`` or ``blueprint.cli`` with ``with_appcontext``, an app context will already be active at that point. :issue:`2410` - ``SessionInterface.get_expiration_time`` uses a timezone-aware value. :pr:`4645` - View functions can return generators directly instead of wrapping them in a ``Response``. :pr:`4629` - Add ``stream_template`` and ``stream_template_string`` functions to render a template as a stream of pieces. :pr:`4629` - A new implementation of context preservation during debugging and testing. :pr:`4666` - ``request``, ``g``, and other context-locals point to the correct data when running code in the interactive debugger console. :issue:`2836` - Teardown functions are always run at the end of the request, even if the context is preserved. They are also run after the preserved context is popped. - ``stream_with_context`` preserves context separately from a ``with client`` block. It will be cleaned up when ``response.get_data()`` or ``response.close()`` is called. - Allow returning a list from a view function, to convert it to a JSON response like a dict is. :issue:`4672` - When type checking, allow ``TypedDict`` to be returned from view functions. :pr:`4695` - Remove the ``--eager-loading/--lazy-loading`` options from the ``flask run`` command. The app is always eager loaded the first time, then lazily loaded in the reloader. The reloader always prints errors immediately but continues serving. Remove the internal ``DispatchingApp`` middleware used by the previous implementation. :issue:`4715` ``` ### 2.1.3 ``` ------------- Released 2022-07-13 - Inline some optional imports that are only used for certain CLI commands. :pr:`4606` - Relax type annotation for ``after_request`` functions. :issue:`4600` - ``instance_path`` for namespace packages uses the path closest to the imported submodule. :issue:`4610` - Clearer error message when ``render_template`` and ``render_template_string`` are used outside an application context. :pr:`4693` ``` ### 2.1.2 ``` ------------- Released 2022-04-28 - Fix type annotation for ``json.loads``, it accepts str or bytes. :issue:`4519` - The ``--cert`` and ``--key`` options on ``flask run`` can be given in either order. :issue:`4459` ``` ### 2.1.1 ``` ------------- Released on 2022-03-30 - Set the minimum required version of importlib_metadata to 3.6.0, which is required on Python &lt; 3.10. :issue:`4502` ``` ### 2.1.0 ``` ------------- Released 2022-03-28 - Drop support for Python 3.6. :pr:`4335` - Update Click dependency to &gt;= 8.0. :pr:`4008` - Remove previously deprecated code. :pr:`4337` - The CLI does not pass ``script_info`` to app factory functions. - ``config.from_json`` is replaced by ``config.from_file(name, load=json.load)``. - ``json`` functions no longer take an ``encoding`` parameter. - ``safe_join`` is removed, use ``werkzeug.utils.safe_join`` instead. - ``total_seconds`` is removed, use ``timedelta.total_seconds`` instead. - The same blueprint cannot be registered with the same name. Use ``name=`` when registering to specify a unique name. - The test client&#x27;s ``as_tuple`` parameter is removed. Use ``response.request.environ`` instead. :pr:`4417` - Some parameters in ``send_file`` and ``send_from_directory`` were renamed in 2.0. The deprecation period for the old names is extended to 2.2. Be sure to test with deprecation warnings visible. - ``attachment_filename`` is renamed to ``download_name``. - ``cache_timeout`` is renamed to ``max_age``. - ``add_etags`` is renamed to ``etag``. - ``filename`` is renamed to ``path``. - The ``RequestContext.g`` property is deprecated. Use ``g`` directly or ``AppContext.g`` instead. :issue:`3898` - ``copy_current_request_context`` can decorate async functions. :pr:`4303` - The CLI uses ``importlib.metadata`` instead of ``setuptools`` to load command entry points. :issue:`4419` - Overriding ``FlaskClient.open`` will not cause an error on redirect. :issue:`3396` - Add an ``--exclude-patterns`` option to the ``flask run`` CLI command to specify patterns that will be ignored by the reloader. :issue:`4188` - When using lazy loading (the default with the debugger), the Click context from the ``flask run`` command remains available in the loader thread. :issue:`4460` - Deleting the session cookie uses the ``httponly`` flag. :issue:`4485` - Relax typing for ``errorhandler`` to allow the user to use more precise types and decorate the same function multiple times. :issue:`4095, 4295, 4297` - Fix typing for ``__exit__`` methods for better compatibility with ``ExitStack``. :issue:`4474` - From Werkzeug, for redirect responses the ``Location`` header URL will remain relative, and exclude the scheme and domain, by default. :pr:`4496` - Add ``Config.from_prefixed_env()`` to load config values from environment variables that start with ``FLASK_`` or another prefix. This parses values as JSON by default, and allows setting keys in nested dicts. :pr:`4479` ``` ### 2.0.3 ``` ------------- Released 2022-02-14 - The test client&#x27;s ``as_tuple`` parameter is deprecated and will be removed in Werkzeug 2.1. It is now also deprecated in Flask, to be removed in Flask 2.1, while remaining compatible with both in 2.0.x. Use ``response.request.environ`` instead. :pr:`4341` - Fix type annotation for ``errorhandler`` decorator. :issue:`4295` - Revert a change to the CLI that caused it to hide ``ImportError`` tracebacks when importing the application. :issue:`4307` - ``app.json_encoder`` and ``json_decoder`` are only passed to ``dumps`` and ``loads`` if they have custom behavior. This improves performance, mainly on PyPy. :issue:`4349` - Clearer error message when ``after_this_request`` is used outside a request context. :issue:`4333` ``` ### 2.0.2 ``` ------------- Released 2021-10-04 - Fix type annotation for ``teardown_*`` methods. :issue:`4093` - Fix type annotation for ``before_request`` and ``before_app_request`` decorators. :issue:`4104` - Fixed the issue where typing requires template global decorators to accept functions with no arguments. :issue:`4098` - Support View and MethodView instances with async handlers. :issue:`4112` - Enhance typing of ``app.errorhandler`` decorator. :issue:`4095` - Fix registering a blueprint twice with differing names. :issue:`4124` - Fix the type of ``static_folder`` to accept ``pathlib.Path``. :issue:`4150` - ``jsonify`` handles ``decimal.Decimal`` by encoding to ``str``. :issue:`4157` - Correctly handle raising deferred errors in CLI lazy loading. :issue:`4096` - The CLI loader handles ``**kwargs`` in a ``create_app`` function. :issue:`4170` - Fix the order of ``before_request`` and other callbacks that trigger before the view returns. They are called from the app down to the closest nested blueprint. :issue:`4229` ``` ### 2.0.1 ``` ------------- Released 2021-05-21 - Re-add the ``filename`` parameter in ``send_from_directory``. The ``filename`` parameter has been renamed to ``path``, the old name is deprecated. :pr:`4019` - Mark top-level names as exported so type checking understands imports in user projects. :issue:`4024` - Fix type annotation for ``g`` and inform mypy that it is a namespace object that has arbitrary attributes. :issue:`4020` - Fix some types that weren&#x27;t available in Python 3.6.0. :issue:`4040` - Improve typing for ``send_file``, ``send_from_directory``, and ``get_send_file_max_age``. :issue:`4044`, :pr:`4026` - Show an error when a blueprint name contains a dot. The ``.`` has special meaning, it is used to separate (nested) blueprint names and the endpoint name. :issue:`4041` - Combine URL prefixes when nesting blueprints that were created with a ``url_prefix`` value. :issue:`4037` - Revert a change to the order that URL matching was done. The URL is again matched after the session is loaded, so the session is available in custom URL converters. :issue:`4053` - Re-add deprecated ``Config.from_json``, which was accidentally removed early. :issue:`4078` - Improve typing for some functions using ``Callable`` in their type signatures, focusing on decorator factories. :issue:`4060` - Nested blueprints are registered with their dotted name. This allows different blueprints with the same name to be nested at different locations. :issue:`4069` - ``register_blueprint`` takes a ``name`` option to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names for ``url_for``. Registering the same blueprint with the same name multiple times is deprecated. :issue:`1091` - Improve typing for ``stream_with_context``. :issue:`4052` ``` ### 2.0.0 ``` ------------- Released 2021-05-11 - Drop support for Python 2 and 3.5. - Bump minimum versions of other Pallets projects: Werkzeug &gt;= 2, Jinja2 &gt;= 3, MarkupSafe &gt;= 2, ItsDangerous &gt;= 2, Click &gt;= 8. Be sure to check the change logs for each project. For better compatibility with other applications (e.g. Celery) that still require Click 7, there is no hard dependency on Click 8 yet, but using Click 7 will trigger a DeprecationWarning and Flask 2.1 will depend on Click 8. - JSON support no longer uses simplejson. To use another JSON module, override ``app.json_encoder`` and ``json_decoder``. :issue:`3555` - The ``encoding`` option to JSON functions is deprecated. :pr:`3562` - Passing ``script_info`` to app factory functions is deprecated. This was not portable outside the ``flask`` command. Use ``click.get_current_context().obj`` if it&#x27;s needed. :issue:`3552` - The CLI shows better error messages when the app failed to load when looking up commands. :issue:`2741` - Add ``SessionInterface.get_cookie_name`` to allow setting the session cookie name dynamically. :pr:`3369` - Add ``Config.from_file`` to load config using arbitrary file loaders, such as ``toml.load`` or ``json.load``. ``Config.from_json`` is deprecated in favor of this. :pr:`3398` - The ``flask run`` command will only defer errors on reload. Errors present during the initial call will cause the server to exit with the traceback immediately. :issue:`3431` - ``send_file`` raises a ``ValueError`` when passed an ``io`` object in text mode. Previously, it would respond with 200 OK and an empty file. :issue:`3358` - When using ad-hoc certificates, check for the cryptography library instead of PyOpenSSL. :pr:`3492` - When specifying a factory function with ``FLASK_APP``, keyword argument can be passed. :issue:`3553` - When loading a ``.env`` or ``.flaskenv`` file, the current working directory is no longer changed to the location of the file. :pr:`3560` - When returning a ``(response, headers)`` tuple from a view, the headers replace rather than extend existing headers on the response. For example, this allows setting the ``Content-Type`` for ``jsonify()``. Use ``response.headers.extend()`` if extending is desired. :issue:`3628` - The ``Scaffold`` class provides a common API for the ``Flask`` and ``Blueprint`` classes. ``Blueprint`` information is stored in attributes just like ``Flask``, rather than opaque lambda functions. This is intended to improve consistency and maintainability. :issue:`3215` - Include ``samesite`` and ``secure`` options when removing the session cookie. :pr:`3726` - Support passing a ``pathlib.Path`` to ``static_folder``. :pr:`3579` - ``send_file`` and ``send_from_directory`` are wrappers around the implementations in ``werkzeug.utils``. :pr:`3828` - Some ``send_file`` parameters have been renamed, the old names are deprecated. ``attachment_filename`` is renamed to ``download_name``. ``cache_timeout`` is renamed to ``max_age``. ``add_etags`` is renamed to ``etag``. :pr:`3828, 3883` - ``send_file`` passes ``download_name`` even if ``as_attachment=False`` by using ``Content-Disposition: inline``. :pr:`3828` - ``send_file`` sets ``conditional=True`` and ``max_age=None`` by default. ``Cache-Control`` is set to ``no-cache`` if ``max_age`` is not set, otherwise ``public``. This tells browsers to validate conditional requests instead of using a timed cache. :pr:`3828` - ``helpers.safe_join`` is deprecated. Use ``werkzeug.utils.safe_join`` instead. :pr:`3828` - The request context does route matching before opening the session. This could allow a session interface to change behavior based on ``request.endpoint``. :issue:`3776` - Use Jinja&#x27;s implementation of the ``|tojson`` filter. :issue:`3881` - Add route decorators for common HTTP methods. For example, ``app.post(&quot;/login&quot;)`` is a shortcut for ``app.route(&quot;/login&quot;, methods=[&quot;POST&quot;])``. :pr:`3907` - Support async views, error handlers, before and after request, and teardown functions. :pr:`3412` - Support nesting blueprints. :issue:`593, 1548`, :pr:`3923` - Set the default encoding to &quot;UTF-8&quot; when loading ``.env`` and ``.flaskenv`` files to allow to use non-ASCII characters. :issue:`3931` - ``flask shell`` sets up tab and history completion like the default ``python`` shell if ``readline`` is installed. :issue:`3941` - ``helpers.total_seconds()`` is deprecated. Use ``timedelta.total_seconds()`` instead. :pr:`3962` - Add type hinting. :pr:`3973`. ``` ### 1.1.4 ``` ------------- Released 2021-05-13 - Update ``static_folder`` to use ``_compat.fspath`` instead of ``os.fspath`` to continue supporting Python &lt; 3.6 :issue:`4050` ``` ### 1.1.3 ``` ------------- Released 2021-05-13 - Set maximum versions of Werkzeug, Jinja, Click, and ItsDangerous. :issue:`4043` - Re-add support for passing a ``pathlib.Path`` for ``static_folder``. :pr:`3579` ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/flask - Changelog: https://pyup.io/changelogs/flask/ - Homepage: https://palletsprojects.com/p/flask </details> ### Update [Flask-Admin](https://pypi.org/project/Flask-Admin) from **1.5.7** to **1.6.1**. <details> <summary>Changelog</summary> ### 1.6.1 ``` ----- * SQLAlchemy 2.x support * General updates and bug fixes * Dropped WTForms 1 support ``` ### 1.6.0 ``` ----- * Dropped Python 2 support * WTForms 3.0 support * Various fixes ``` ### 1.5.8 ``` ----- * SQLAlchemy 1.4.5+ compatibility fixes * Redis CLI fixes ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/flask-admin - Changelog: https://pyup.io/changelogs/flask-admin/ - Repo: https://github.com/flask-admin/flask-admin/ - Docs: https://pythonhosted.org/Flask-Admin/ </details> ### Update [Flask-SQLAlchemy](https://pypi.org/project/Flask-SQLAlchemy) from **2.4.4** to **3.0.3**. <details> <summary>Changelog</summary> ### 3.0.2 ``` ------------- Released 2022-10-14 - Update compatibility with SQLAlchemy 2. :issue:`1122` ``` ### 3.0.1 ``` ------------- Released 2022-10-11 - Export typing information instead of using external typeshed definitions. :issue:`1112` - If default engine options are set, but ``SQLALCHEMY_DATABASE_URI`` is not set, an invalid default bind will not be configured. :issue:`1117` ``` ### 3.0.0 ``` ------------- Released 2022-10-04 - Drop support for Python 2, 3.4, 3.5, and 3.6. - Bump minimum version of Flask to 2.2. - Bump minimum version of SQLAlchemy to 1.4.18. - Remove previously deprecated code. - The session is scoped to the current app context instead of the thread. This requires that an app context is active. This ensures that the session is cleaned up after every request. - An active Flask application context is always required to access ``session`` and ``engine``, regardless of if an application was passed to the constructor. :issue:`508, 944` - Different bind keys use different SQLAlchemy ``MetaData`` registries, allowing tables in different databases to have the same name. Bind keys are stored and looked up on the resulting metadata rather than the model or table. - ``SQLALCHEMY_DATABASE_URI`` does not default to ``sqlite:///:memory:``. An error is raised if neither it nor ``SQLALCHEMY_BINDS`` define any engines. :pr:`731` - Configuring SQLite with a relative path is relative to ``app.instance_path`` instead of ``app.root_path``. The instance folder is created if necessary. :issue:`462` - Added ``get_or_404``, ``first_or_404``, ``one_or_404``, and ``paginate`` methods to the extension object. These use SQLAlchemy&#x27;s preferred ``session.execute(select())`` pattern instead of the legacy query interface. :issue:`1088` - Setup methods that create the engines and session are renamed with a leading underscore. They are considered internal interfaces which may change at any time. - All parameters to ``SQLAlchemy`` except ``app`` are keyword-only. - Renamed the ``bind`` parameter to ``bind_key`` and removed the ``app`` parameter from various ``SQLAlchemy`` methods. - The extension object uses ``__getattr__`` to alias names from the SQLAlchemy package, rather than copying them as attributes. - The extension object is stored directly as ``app.extensions[&quot;sqlalchemy&quot;]``. :issue:`698` - The session class can be customized by passing the ``class_`` key in the ``session_options`` parameter. :issue:`327` - ``SignallingSession`` is renamed to ``Session``. - ``Session.get_bind`` more closely matches the base implementation. - Model classes and the ``db`` instance are available without imports in ``flask shell``. :issue:`1089` - The ``CamelCase`` to ``snake_case`` table name converter handles more patterns correctly. If model that was already created in the database changed, either use Alembic to rename the table, or set ``__tablename__`` to keep the old name. :issue:`406` - ``Model`` ``repr`` distinguishes between transient and pending instances. :issue:`967` - A custom model class can implement ``__init_subclass__`` with class parameters. :issue:`1002` - ``db.Table`` is a subclass instead of a function. - The ``engine_options`` parameter is applied as defaults before per-engine configuration. - ``SQLALCHEMY_BINDS`` values can either be an engine URL, or a dict of engine options including URL, for each bind. ``SQLALCHEMY_DATABASE_URI`` and ``SQLALCHEMY_ENGINE_OPTIONS`` correspond to the ``None`` key and take precedence. :issue:`783` - Engines are created when calling ``init_app`` rather than the first time they are accessed. :issue:`698` - ``db.engines`` exposes the map of bind keys to engines for the current app. - ``get_engine``, ``get_tables_for_bind``, and ``get_binds`` are deprecated. - SQLite driver-level URIs that look like ``sqlite:///file:name.db?uri=true`` are supported. :issue:`998, 1045` - SQLite engines do not use ``NullPool`` if ``pool_size`` is 0. - MySQL engines use the &quot;utf8mb4&quot; charset by default. :issue:`875` - MySQL engines do not set ``pool_size`` to 10. - MySQL engines don&#x27;t set a default for ``pool_recycle`` if not using a queue pool. :issue:`803` - ``Query`` is renamed from ``BaseQuery``. - Added ``Query.one_or_404``. - The query class is applied to ``backref`` in ``relationship``. :issue:`417` - Creating ``Pagination`` objects manually is no longer a public API. They should be created with ``db.paginate`` or ``query.paginate``. :issue:`1088` - ``Pagination.iter_pages`` and ``Query.paginate`` parameters are keyword-only. - ``Pagination`` is iterable, iterating over its items. :issue:`70` - Pagination count query is more efficient. - ``Pagination.iter_pages`` is more efficient. :issue:`622` - ``Pagination.iter_pages`` ``right_current`` parameter is inclusive. - Pagination ``per_page`` cannot be 0. :issue:`1091` - Pagination ``max_per_page`` defaults to 100. :issue:`1091` - Added ``Pagination.first`` and ``last`` properties, which give the number of the first and last item on the page. :issue:`567` - ``SQLALCHEMY_RECORD_QUERIES`` is disabled by default, and is not enabled automatically with ``app.debug`` or ``app.testing``. :issue:`1092` - ``get_debug_queries`` is renamed to ``get_recorded_queries`` to better match the config and functionality. - Recorded query info is a dataclass instead of a tuple. The ``context`` attribute is renamed to ``location``. Finding the location uses a more inclusive check. - ``SQLALCHEMY_TRACK_MODIFICATIONS`` is disabled by default. :pr:`727` - ``SQLALCHEMY_COMMIT_ON_TEARDOWN`` is deprecated. It can cause various design issues that are difficult to debug. Call ``db.session.commit()`` directly instead. :issue:`216` ``` ### 2.5.1 ``` ------------- Released 2021-03-18 - Fix compatibility with Python 2.7. ``` ### 2.5.0 ``` ------------- Released 2021-03-18 - Update to support SQLAlchemy 1.4. - SQLAlchemy ``URL`` objects are immutable. Some internal methods have changed to return a new URL instead of ``None``. :issue:`885` ``` </details> <details> <summary>Links</summary> - PyPI: https://pypi.org/project/flask-sqlalchemy - Changelog: https://pyup.io/changelogs/flask-sqlalchemy/ - Docs: https://pythonhosted.org/Flask-SQLAlchemy/ </details> ### Update [SQLAlchemy](https://pypi.org/project/SQLAlchemy) from **1.3.20** to **2.0.5.post1**. <details> <summary>Changelog</summary> ### 2.0.5.post1 ``` :released: March 5, 2023 .. change:: :tags: bug, orm :tickets: 9418 Added constructor arguments to the built-in mapping collection types including :class:`.KeyFuncDict`, :func:`_orm.attribute_keyed_dict`, :func:`_orm.column_keyed_dict` so that these dictionary types may be constructed in place given the data up front; this provides further compatibility with tools such as Python dataclasses ``.asdict()`` which relies upon invoking these classes directly as ordinary dictionary classes. .. change:: :tags: bug, orm, regression :tickets: 9424 Fixed multiple regressions due to :ticket:`8372`, involving :func:`_orm.attribute_mapped_collection` (now called :func:`_orm.attribute_keyed_dict`). First, the collection was no longer usable with &quot;key&quot; attributes that were not themselves ordinary mapped attributes; attributes linked to descriptors and/or association proxy attributes have been fixed. Second, if an event or other operation needed access to the &quot;key&quot; in order to populate the dictionary from an mapped attribute that was not loaded, this also would raise an error inappropriately, rather than trying to load the attribute as was the behavior in 1.4. This is also fixed. For both cases, the behavior of :ticket:`8372` has been expanded. :ticket:`8372` introduced an error that raises when the derived key that would be used as a mapped dictionary key is effectively unassigned. In this change, a warning only is emitted if the effective value of the &quot;.key&quot; attribute is ``None``, where it cannot be unambiguously determined if this ``None`` was intentional or not. ``None`` will be not supported as mapped collection dictionary keys going forward (as it typically refers to NULL which means &quot;unknown&quot;). Setting :paramref:`_orm.attribute_keyed_dict.ignore_unpopulated_attribute` will now cause such ``None`` keys to be ignored as well. .. change:: :tags: engine, performance :tickets: 9343 A small optimization to the Cython implementation of :class:`.Result` using a cdef for a particular int value to avoid Python overhead. Pull request courtesy Matus Valo. .. change:: :tags: bug, mssql :tickets: 9414 Fixed issue in the new :class:`.Uuid` datatype which prevented it from working with the pymssql driver. As pymssql seems to be maintained again, restored testing support for pymssql. .. change:: :tags: bug, mssql Tweaked the pymssql dialect to take better advantage of RETURNING for INSERT statements in order to retrieve last inserted primary key values, in the same way as occurs for the mssql+pyodbc dialect right now. .. change:: :tags: bug, orm Identified that the ``sqlite`` and ``mssql+pyodbc`` dialects are now compatible with the SQLAlchemy ORM&#x27;s &quot;versioned rows&quot; feature, since SQLAlchemy now computes rowcount for a RETURNING statement in this specific case by counting the rows returned, rather than relying upon ``cursor.rowcount``. In particular, the ORM versioned rows use case (documented at :ref:`mapper_version_counter`) should now be fully supported with the SQL Server pyodbc dialect. .. change:: :tags: bug, postgresql :tickets: 9349 Fixed issue in PostgreSQL :class:`_postgresql.ExcludeConstraint` where literal values were being compiled as bound parameters and not direct inline values as is required for DDL. .. change:: :tags: bug, typing Fixed bug where the :meth:`_engine.Connection.scalars` method was not typed as allowing a multiple-parameters list, which is now supported using insertmanyvalues operations. .. change:: :tags: bug, typing :tickets: 9376 Improved typing for the mapping passed to :meth:`.Insert.values` and :meth:`.Update.values` to be more open-ended about collection type, by indicating read-only ``Mapping`` instead of writeable ``Dict`` which would error out on too limited of a key type. .. change:: :tags: schema Validate that when provided the :paramref:`_schema.MetaData.schema` argument of :class:`_schema.MetaData` is a string. .. change:: :tags: typing, usecase :tickets: 9338 Exported the type returned by :meth:`_orm.scoped_session.query_property` using a new public type :class:`.orm.QueryPropertyDescriptor`. .. change:: :tags: bug, mysql, postgresql :tickets: 5648 The support for pool ping listeners to receive exception events via the :meth:`.DialectEvents.handle_error` event added in 2.0.0b1 for :ticket:`5648` failed to take into account dialect-specific ping routines such as that of MySQL and PostgreSQL. The dialect feature has been reworked so that all dialects participate within event handling. Additionally, a new boolean element :attr:`.ExceptionContext.is_pre_ping` is added which identifies if this operation is occurring within the pre-ping operation. For this release, third party dialects which implement a custom :meth:`_engine.Dialect.do_ping` method can opt in to the newly improved behavior by having their method no longer catch exceptions or check exceptions for &quot;is_disconnect&quot;, instead just propagating all exceptions outwards. Checking the exception for &quot;is_disconnect&quot; is now done by an enclosing method on the default dialect, which ensures that the event hook is invoked for all exception scenarios before testing the exception as a &quot;disconnect&quot; exception. If an existing ``do_ping()`` method continues to catch exceptions and check &quot;is_disconnect&quot;, it will continue to work as it did previously, but ``handle_error`` hooks will not have access to the exception if it isn&#x27;t propagated outwards. .. change:: :tags: bug, ext :tickets: 9367 Fixed issue in automap where calling :meth:`_automap.AutomapBase.prepare` from a specific mapped class, rather than from the :class:`_automap.AutomapBase` directly, would not use the correct base class when automap detected new tables, instead using the given class, leading to mappers trying to configure inheritance. While one should normally call :meth:`_automap.AutomapBase.prepare` from the base in any case, it shouldn&#x27;t misbehave that badly when called from a subclass. .. change:: :tags: bug, sqlite, regression :tickets: 9379 Fixed regression for SQLite connections where use of the ``deterministic`` parameter when establishing database functions would fail for older SQLite versions, those prior to version 3.8.3. The version checking logic has been improved to accommodate for this case. .. change:: :tags: bug, typing :tickets: 9391 Added missing init overload to the :class:`_types.Numeric` type object so that pep-484 type checkers may properly resolve the complete type, deriving from the :paramref:`_types.Numeric.asdecimal` parameter whether ``Decimal`` or ``float`` objects will be represented. .. change:: :tags: bug, typing :tickets: 9398 Fixed typing bug where :meth:`_sql.Select.from_statement` would not accept :func:`_sql.text` or :class:`.TextualSelect` objects as a valid type. Additionally repaired the :class:`.TextClause.columns` method to have a return type, which was missing. .. change:: :tags: bug, orm declarative :tickets: 9332 Fixed issue where new :paramref:`_orm.mapped_column.use_existing_column` feature would not work if the two same-named columns were mapped under attribute names that were differently-named from an explicit name given to the column itself. The attribute names can now be differently named when using this parameter. .. change:: :tags: bug, orm :tickets: 9373 Added support for the :paramref:`_orm.Mapper.polymorphic_load` parameter to be applied to each mapper in an inheritance hierarchy more than one level deep, allowing columns to load for all classes in the hierarchy that indicate ``&quot;selectin&quot;`` using a single statement, rather than ignoring elements on those intermediary classes that nonetheless indicate they also would participate in ``&quot;selectin&quot;`` loading and were not part of the base-most SELECT statement. .. change:: :tags: bug, orm :tickets: 8853, 9335 Continued the fix for :ticket:`8853`, allowing the :class:`_orm.Mapped` name to be fully qualified regardless of whether or not ``from __annotations__ import future`` were present. This issue first fixed in 2.0.0b3 confirmed that this case worked via the test suite, however the test suite apparently was not testing the behavior for the name :class:`_orm.Mapped` not being locally present at all; string resolution has been updated to ensure the :class:`_orm.Mapped` symbol is locatable as applies to how the ORM uses these functions. .. change:: :tags: bug, typing :tickets: 9340 Fixed typing issue where :func:`_orm.with_polymorphic` would not record the class type correctly. .. change:: :tags: bug, ext, regression :tickets: 9380 Fixed regression caused by typing added to ``sqlalchemy.ext.mutable`` for :ticket:`8667`, where the semantics of the ``.pop()`` method changed such that the method was non-working. Pull request courtesy Nils Philippsen. .. change:: :tags: bug, sql, regression :tickets: 9390 Restore the :func:`.nullslast` and :func:`.nullsfirst` legacy functions into the ``sqlalchemy`` import namespace. Previously, the newer :func:`.nulls_last` and :func:`.nulls_first` functions were available, but the legacy ones were inadvertently removed. .. change:: :tags: bug, postgresql :tickets: 9401 Fixed issue where the PostgreSQL :class:`_postgresql.ExcludeConstraint` construct would not be copyable within operations such as :meth:`_schema.Table.to_metadata` as well as within some Alembic scenarios, if the constraint contained textual expression elements. .. change:: :tags: bug, engine :tickets: 9423 Fixed bug where :class:`_engine.Row` objects could not be reliably unpickled across processes due to an accidental reliance on an unstable hash value. .. changelog:: ``` ### 2.0.4 ``` :released: February 17, 2023 .. change:: :tags: bug, orm, regression :tickets: 9273 Fixed regression introduced in version 2.0.2 due to :ticket:`9217` where using DML RETURNING statements, as well as :meth:`_sql.Select.from_statement` constructs as was &quot;fixed&quot; in :ticket:`9217`, in conjunction with ORM mapped classes that used expressions such as with :func:`_orm.column_property`, would lead to an internal error within Core where it would attempt to match the expression by name. The fix repairs the Core issue, and also adjusts the fix in :ticket:`9217` to not take effect for the DML RETURNING use case, where it adds unnecessary overhead. .. change:: :tags: usecase, typing :tickets: 9321 Improved the typing support for the :ref:`hybrids_toplevel` extension, updated all documentation to use ORM Annotated Declarative mappings, and added a new modifier called :attr:`.hybrid_property.inplace`. This modifier provides a way to alter the state of a :class:`.hybrid_property` **in place**, which is essentially what very early versions of hybrids did, before SQLAlchemy version 1.2.0 :ticket:`3912` changed this to remove in-place mutation. This in-place mutation is now restored on an **opt-in** basis to allow a single hybrid to have multiple methods set up, without the need to name all the methods the same and without the need to carefully &quot;chain&quot; differently-named methods in order to maintain the composition. Typing tools such as Mypy and Pyright do not allow same-named methods on a class, so with this change a succinct method of setting up hybrids with typing support is restored. .. seealso:: :ref:`hybrid_pep484_naming` .. change:: :tags: bug, orm Marked the internal ``EvaluatorCompiler`` module as private to the ORM, and renamed it to ``_EvaluatorCompiler``. For users that may have been relying upon this, the name ``EvaluatorCompiler`` is still present, however this use is not supported and will be removed in a future release. .. change:: :tags: orm, use_case :tickets: 9297 To accommodate a change in column ordering used by ORM Declarative in SQLAlchemy 2.0, a new parameter :paramref:`_orm.mapped_column.sort_order` has been added that can be used to control the order of the columns defined in the table by the ORM, for common use cases such as mixins with primary key columns that should appear first in tables. The change notes at :ref:`change_9297` illustrate the default change in ordering behavior (which is part of all SQLAlchemy 2.0 releases) as well as use of the :paramref:`_orm.mapped_column.sort_order` to control column ordering when using mixins and multiple classes (new in 2.0.4). .. seealso:: :ref:`change_9297` .. change:: :tags: sql :tickets: 9277 Added public property :attr:`_schema.Table.autoincrement_column` that returns the column identified as autoincrementing in the column. .. change:: :tags: oracle, bug :tickets: 9295 Adjusted the behavior of the ``thick_mode`` parameter for the :ref:`oracledb` dialect to correctly accept ``False`` as a value. Previously, only ``None`` would indicate that thick mode should be disabled. .. change:: :tags: usecase, orm :tickets: 9298 The :meth:`_orm.Session.refresh` method will now immediately load a relationship-bound attribute that is explicitly named within the :paramref:`_orm.Session.refresh.attribute_names` collection even if it is currently linked to the &quot;select&quot; loader, which normally is a &quot;lazy&quot; loader that does not fire off during a refresh. The &quot;lazy loader&quot; strategy will now detect that the operation is specifically a user-initiated :meth:`_orm.Session.refresh` operation which named this attribute explicitly, and will then call upon the &quot;immediateload&quot; strategy to actually emit SQL to load the attribute. This should be helpful in particular for some asyncio situations where the loading of an unloaded lazy-loaded attribute must be forced, without using the actual lazy-loading attribute pattern not supported in asyncio. .. change:: :tags: bug, sql :tickets: 9313 Fixed issue where element types of a tuple value would be hardcoded to take on the types from a compared-to tuple, when the comparison were using the :meth:`.ColumnOperators.in_` operator. This was inconsistent with the usual way that types are determined for a binary expression, which is that the actual element type on the right side is considered first before applying the left-hand-side type. .. change:: :tags: usecase, orm declarative :tickets: 9266 Added new parameter ``dataclasses_callable`` to both the :class:`_orm.MappedAsDataclass` class as well as the :meth:`_orm.registry.mapped_as_dataclass` method which allows an alternative callable to Python ``dataclasses.dataclass`` to be used in order to produce dataclasses. The use case here is to drop in Pydantic&#x27;s dataclass function instead. Adjustments have been made to the mixin support added for :ticket:`9179` in version 2.0.1 so that the ``__annotations__`` collection of the mixin is rewritten to not include the :class:`_orm.Mapped` container, in the same way as occurs with mapped classes, so that the Pydantic dataclasses constructor is not exposed to unknown types. .. seealso:: :ref:`dataclasses_pydantic` .. changelog:: ``` ### 2.0.3 ``` :released: February 9, 2023 .. change:: :tags: typing, bug :tickets: 9254 Remove ``typing.Self`` workaround, now using :pep:`673` for most methods that return ``Self``. As a consequence of this change ``mypy&gt;=1.0.0`` is now required to type check SQLAlchemy code. Pull request courtesy Yurii Karabas. .. change:: :tags: bug, sql, regression :tickets: 9271 Fixed critical regression in SQL expression formulation in the 2.0 series due to :ticket:`7744` which improved support for SQL expressions that contained many elements against the same operator repeatedly; parenthesis grouping would be lost with expression elements beyond the first two elements. .. changelog:: ``` ### 2.0.2 ``` :released: February 6, 2023 .. change:: :tags: bug, orm declarative :tickets: 9249 Fixed regression caused by the fix for :ticket:`9171`, which itself was fixing a regression, involving the mechanics of ``__init__()`` on classes that extend from :class:`_orm.DeclarativeBase`. The change made it such that ``__init__()`` was applied to the user-defined base if there were no ``__init__()`` method directly on the class. This has been adjusted so that ``__init__()`` is applied only if no other class in the hierarchy of the user-defined base has an ``__init__()`` method. This again allows user-defined base classes based on :class:`_orm.DeclarativeBase` to include mixins that themselves include a custom ``__init__()`` method. .. change:: :tags: bug, mysql, regression :tickets: 9251 Fixed regression caused by issue :ticket:`9058` which adjusted the MySQL dialect&#x27;s ``has_table()`` to again use &quot;DESCRIBE&quot;, where the specific error code raised by MySQL version 8 when using a non-existent schema name was unexpected and failed to be interpreted as a boolean result. .. change:: :tags: bug, sqlite :tickets: 9251 Fixed the SQLite dialect&#x27;s ``has_table()`` function to correctly report False for queries that include a non-None schema name for a schema that doesn&#x27;t exist; previously, a database error was raised. .. change:: :tags: bug, orm declarative :tickets: 9226 Fixed issue in ORM Declarative Dataclass mappings related to newly added support for mixins added in 2.0.1 via :ticket:`9179`, where a combination of using mixins plus ORM inheritance would mis-classify fields in some cases leading to field-level dataclass arguments such as ``init=False`` being lost. .. change:: :tags: bug, orm, ression :tickets: 9232 Fixed obscure ORM inheritance issue caused by :ticket:`8705` where some scenarios of inheriting mappers that indicated groups of columns from the local table and the inheriting table together under a :func:`_orm.column_property` would nonetheless warn that properties of the same name were being combined implicitly. .. change:: :tags: orm, bug, regression :tickets: 9228 Fixed regression where using the :paramref:`_orm.Mapper.version_id_col` feature with a regular Python-side incrementing column would fail to work for SQLite and other databases that don&#x27;t support &quot;rowcount&quot; with &quot;RETURNING&quot;, as &quot;RETURNING&quot; would be assumed for such columns even though that&#x27;s not what actually takes place. .. change:: :tags: bug, orm declarative :tickets: 9240 Repaired ORM Declarative mappings to allow for the :paramref:`_orm.Mapper.primary_key` parameter to be specified within ``__mapper_args__`` when using :func:`_orm.mapped_column`. Despite this usage being directly in the 2.0 documentation, the :class:`_orm.Mapper` was not accepting the :func:`_orm.mapped_column` construct in this context. Ths feature was already working for the :paramref:`_orm.Mapper.version_id_col` and :paramref:`_orm.Mapper.polymorphic_on` parameters. As part of this change, the ``__mapper_args__`` attribute may be specified without using :func:`_orm.declared_attr` on a non-mapped mixin class, including a ``&quot;primary_key&quot;`` entry that refers to :class:`_schema.Column` or :func:`_orm.mapped_column` objects locally present on the mixin; Declarative will also translate these columns into the correct ones for a particular mapped class. This again was working already for the :paramref:`_orm.Mapper.version_id_col` and :paramref:`_orm.Mapper.polymorphic_on` parameters. Additionally, elements within ``&quot;primary_key&quot;`` may be indicated as string names of existing mapped properties. .. change:: :tags: usecase, sql :tickets: 8780 Added a full suite of new SQL bitwise operators, for performing database-side bitwise expressions on appropriate data values such as integers, bit-strings, and similar. Pull request courtesy Yegor Statkevich. .. seealso:: :ref:`operators_bitwise` .. change:: :tags: bug, orm declarative :tickets: 9211 An explicit error is raised if a mapping attempts to mix the use of :class:`_orm.MappedAsDataclass` with :meth:`_orm.registry.mapped_as_dataclass` within the same class hierarchy, as this produces issues with the dataclass function being applied at the wrong time to the mapped class, leading to errors during the mapping process. .. change:: :tags: bug, orm, regression :tickets: 9217 Fixed regression when using :meth:`_sql.Select.from_statement` in an ORM context, where matching of columns to SQL labels based on name alone was disabled for ORM-statements that weren&#x27;t fully textual. This would prevent arbitrary SQL expressions with column-name labels from matching up to the entity to be loaded, which previously would work within the 1.4 and previous series, so the previous behavior has been restored. .. change:: :tags: bug, asyncio :tickets: 9237 Repaired a regression caused by the fix for :ticket:`8419` which caused asyncpg connections to be reset (i.e. transaction ``rollback()`` called) and returned to the pool normally in the case that the connection were not explicitly returned to the connection pool and was instead being intercepted by Python garbage collection, which would fail if the garbage collection operation were being called outside of the asyncio event loop, leading to a large amount of stack trace activity dumped into logging and standard output. The correct behavior is restored, which is that all asyncio connections that are garbage collected due to not being explicitly returned to the connection pool are detached from the pool and discarded, along with a warning, rather than being returned the pool, as they cannot be reliably reset. In the case of asyncpg connections, the asyncpg-specific ``terminate()`` method will be used to end the connection more gracefully within this process as opposed to just dropping it. This change includes a small behavioral change that is hoped to be useful for debugging asyncio applications, where the warning that&#x27;s emitted in the case of asyncio connections being unexpectedly garbage collected has been made slightly more aggressive by moving it outside of a ``try/except`` block and into a ``finally:`` block, where it will emit unconditionally regardless of whether the detach/termination operation succeeded or not. It will also have the effect that applications or test suites which promote Python warnings to exceptions will see this as a full exception raise, whereas previously it was not possible for this warning to actually propagate as an exception. Applications and test suites which need to tolerate this warning in the interim should adjust the Python warnings filter to allow these warnings to not raise. The behavior for traditional sync connections remains unchanged, that garbage collected connections continue to be returned to the pool normally without emitting a warning. This will likely be changed in a future major release to at least emit a similar warning as is emitted for asyncio drivers, as it is a usage error for pooled connections to be intercepted by garbage collection without being properly returned to the pool. .. change:: :tags: usecase, orm :tickets: 9220 Added new event hook :meth:`_orm.MapperEvents.after_mapper_constructed`, which supplies an event hook to take place right as the :class:`_orm.Mapper` object has been fully constructed, but before the :meth:`_orm.registry.configure` call has been called. This allows code that can create additional mappings and table structures based on the initial configuration of a :class:`_orm.Mapper`, which also integrates within Declarative configuration. Previously, when using Declarative, where the :class:`_orm.Mapper` object is created within the class creation process, there was no documented means of running code at this point. The change is to immediately benefit custom mapping schemes such as that of the :ref:`examples_versioned_history` example, which generate additional mappers and tables in response to the creation of mapped classes. .. change:: :tags: usecase, orm :tickets: 9220 The infrequently used :attr:`_orm.Mapper.iterate_properties` attribute and :meth:`_orm.Mapper.get_property` method, which are primarily used internally, no longer implicitly invoke the :meth:`_orm.registry.configure` process. Public access to these methods is extremely rare and the only benefit to having :meth:`_orm.registry.configure` would have been allowing &quot;backref&quot; properties be present in these collections. In order to support the new :meth:`_orm.MapperEvents.after_mapper_constructed` event, iteration and access to the internal :class:`_orm.MapperProperty` objects is now possible without triggering an implicit configure of the mapper itself. The more-public facing route to iteration of all mapper attributes, the :attr:`_orm.Mapper.attrs` collection and similar, will still implicitly invoke the :meth:`_orm.registry.configure` step thus making backref attributes available. In all cases, the :meth:`_orm.registry.configure` is always available to be called directly. .. change:: :tags: bug, examples :tickets: 9220 Reworked the :ref:`examples_versioned_history` to work with version 2.0, while at the same time improving the overall working of this example to use newer APIs, including a newly added hook :meth:`_orm.MapperEvents.after_mapper_constructed`. .. change:: :tags: bug, mysql :tickets: 8626 Added support for MySQL 8&#x27;s new ``AS &lt;name&gt; ON DUPLICATE KEY`` syntax when using :meth:`_mysql.Insert.on_duplicate_key_update`, which is required for newer versions of MySQL 8 as the previous syntax using ``VALUES()`` now emits a deprecation warning with those versions. Server version detection is employed to determine if traditional MariaDB / MySQL &lt; 8 ``VALUES()`` syntax should be used, vs. the newer MySQL 8 required syntax. Pull request courtesy Caspar Wylie. .. changelog:: ``` ### 2.0.1 ``` :released: February 1, 2023 .. change:: :tags: bug, typing :tickets: 9174 Opened up typing on :paramref:`.Select.with_for_update.of` to also accept table and mapped class arguments, as seems to be available for the MySQL dialect. .. change:: :tags: bug, orm, regression :tickets: 9164 Fixed regression where ORM models that used joined table inheritance with a composite foreign key would encounter an internal error in the mapper internals. .. change:: :tags: bug, sql :tickets: 7664 Corrected the fix for :ticket:`7664`, released in version 2.0.0, to also include :class:`.DropSchema` which was inadvertently missed in this fix, allowing stringification without a dialect. The fixes for both constructs is backported to the 1.4 series as of 1.4.47. .. change:: :tags: bug, orm declarative :tickets: 9175 Added support for :pep:`484` ``NewType`` to be used in the :paramref:`_orm.registry.type_annotation_map` as well as within :class:`.Mapped` constructs. These types will behave in the same way as custom subclasses of types right now; they must appear explicitly within the :paramref:`_orm.registry.type_annotation_map` to be mapped. .. change:: :tags: bug, typing :tickets: 9183 Fixed typing for limit/offset methods including :meth:`.Select.limit`, :meth:`.Select.offset`, :meth:`_orm.Query.limit`, :meth:`_orm.Query.offset` to allow ``None``, which is the documented API to &quot;cancel&quot; the current limit/offset. .. change:: :tags: bug, orm declarative :tickets: 9179 When using the :class:`.MappedAsDataclass` superclass, all classes within the hierarchy that are subclasses of this class will now be run through the ``dataclasses.dataclass`` function whether or not they are actually mapped, so that non-ORM fields declared on non-mapped classes within the hierarchy will be used when mapped subclasses are turned into dataclasses. This behavior applies both to intermediary classes mapped with ``__abstract__ = True`` as well as to the user-defined declarative base itself, assuming :class:`.MappedAsDataclass` is present as a superclass for these classes. This allows non-mapped attributes such as ``InitVar`` declarations on superclasses to be used, without the need to run the ``dataclasses.dataclass`` decorator explicitly on each non-mapped class. The new behavior is considered as correct as this is what the :pep:`681` implementation expects when using a superclass to indicate dataclass behavior. .. change:: :tags: bug, typing :tickets: 9170 Fixed typing issue where :func:`_orm.mapped_column` objects typed as :class:`_orm.Mapped` wouldn&#x27;t be accepted in schema constraints such as :class:`_schema.ForeignKey`, :class:`_schema.UniqueConstraint` or :class:`_schema.Index`. .. change:: :tags: bug, orm declarative :tickets: 9187 Added support for :pep:`586` ``Literal[]`` to be used in the :paramref:`_orm.registry.type_annotation_map` as well as within :class:`.Mapped` constructs. To use custom types such as these, they must appear explicitly within the :paramref:`_orm.registry.type_annotation_map` to be mapped. Pull request courtesy Frederik Aalund. As part of this change, the support for :class:`.sqltypes.Enum` in the :paramref:`_orm.registry.type_annotation_map` has been expanded to include support for ``Literal[]`` types consisting of string values to be used, in addition to ``enum.Enum`` datatypes. If a ``Literal[]`` datatype is used within ``Mapped[]`` that is not linked in :paramref:`_orm.registry.type_annotation_map` to a specific datatype, a :class:`.sqltypes.Enum` will be used by default. .. seealso:: :ref:`orm_declarative_mapped_column_enums` .. change:: :tags: bug, orm declarative :tickets: 9200 Fixed issue involving the use of :class:`.sqltypes.Enum` within the :paramref:`_orm.registry.type_annotation_map` where the :paramref:`_sqltypes.Enum.native_enum` parameter would not be correctly copied to the mapped column datatype, if it were overridden as stated in the documentation to set this parameter to False. .. change:: :tags: bug, orm declarative, regression :tickets: 9171 Fixed regression in :class:`.DeclarativeBase` class where the registry&#x27;s default constructor would not be applied to the base itself, which is different from how the previous :func:`_orm.declarative_base` construct works. This would prevent a mapped class with its own ``__init__()`` method from calling ``super().__init__()`` in order to access the registry&#x27;s default constructor and automatically populate attributes, instead hitting ``object.__init__()`` which would raise a ``TypeError`` on any arguments. .. change:: :tags: bug, sql, regression :tickets: 9173 Fixed regression related to the implementation for the new &quot;insertmanyvalues&quot; feature where an internal ``TypeError`` would occur in arrangements where a :func:`_sql.insert` would be referred towards inside of another :func:`_sql.insert` via a CTE; made additional repairs for this use case for positional dialects such as asyncpg when using &quot;insertmanyvalues&quot;. .. change:: :tags: bug, typing :tickets: 9156 Fixed typing for :meth:`_expression.ColumnElement.cast` to accept both ``Type[TypeEngine[T]]`` and ``TypeEngine[T]``; previously only ``TypeEngine[T]`` was accepted. Pull request courtesy Yurii Karabas. .. change:: :tags: bug, orm declarative :tickets: 9177 Improved the ruleset used to interpret :pep:`593` ``Annotated`` types when used with Annotated Declarative mapping, the inner type will be checked for &quot;Optional&quot; in all cases which will be added to the criteria by which the column is set as &quot;nullable&quot; or not; if the type within the ``Annotated`` container is optional (or unioned with ``None``), the column will be considered nullable if there are no explicit :paramref:`_orm.mapped_column.nullable` parameters overriding it. .. change:: :tags: bug, orm :tickets: 9182 Improved the error reporting when linking strategy options from a base class to another attribute that&#x27;s off a subclass, where ``of_type()`` should be used. Previously, when :meth:`.Load.options` is used, the message would lack informative detail that ``of_type()`` should be used, which was not the case when linking the options directly. The informative detail now emits even if :meth:`.Load.options` is used. .. changelog:: ``` ### 2.0.0 ``` :released: January 26, 2023 .. change:: :tags: bug, sql :tickets: 7664 Fixed stringify for a the :class:`.CreateSchema` DDL construct, which would fail with an ``AttributeError`` when stringified without a dialect. Update: Note this fix failed to accommodate for :class:`.DropSchema`; a followup fix in version 2.0.1 repairs this case. The fix for both elements is backported to 1.4.47. .. change:: :tags: usecase, orm extensions :tickets: 5145 Added new feature to :class:`.AutomapBase` for autoload of classes across multiple schemas which may have overlapping names, by providing a :paramref:`.AutomapBase.prepare.modulename_for_table` parameter which allows customization of the ``__module__`` attribute of newly generated classes, as well as a new collection :attr:`.AutomapBase.by_module`, which stores a dot-separated namespace of module names linked to class --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 01:34:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sandman2-jeffknupp#323
No description provided.