0.x Changelog¶
0.30.3¶
Released: 2025-01-26Features¶
- add wrap_exceptions option to exception handler.#
When wrap_exceptions is False, the original SQLAlchemy error message will be raised instead of the wrapped Repository error
Fixes #356 (Bug: wrap_sqlalchemy_exception masks db errors)
References: https://github.com/litestar-org/litestar/issues/356, https://github.com/litestar-org/litestar/pull/363
- simplify configuration hash#
The hashing method on the SQLAlchemy configs can be simplified. This should be enough to define a unique configuration.
References: https://github.com/litestar-org/litestar/pull/366
Bugfixes¶
- use lifespan context manager in Starlette and FastAPI#
Modifies the Starlette and FastAPI integrations to use the lifespan context manager instead of the startup`shutdown` hooks. If the application already has a lifespan set, it is wrapped so that both execute.
References: https://github.com/litestar-org/litestar/issues/367, https://github.com/litestar-org/litestar/pull/368
0.30.2¶
Released: 2025-01-21Features¶
- add hash to config classes#
<!– By submitting this pull request, you agree to: - follow [Litestar’s Code of Conduct](https://github.com/litestar-org/.github/blob/main/CODE_OF_CONDUCT.md) - follow [Litestar’s contribution guidelines](https://github.com/litestar-org/.github/blob/main/CONTRIBUTING.md) - follow the [PSFs’s Code of Conduct](https://www.python.org/psf/conduct/) –> ## Description
Adds hash function to SQLAlchemySyncConfig and SQLAlchemyAsyncConfig classes.
<!– Please add in issue numbers this pull request will close, if applicable Examples: Fixes #4321 or Closes #1234
Ensure you are using a supported keyword to properly link an issue: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword –> ## Closes Closes #357
References: https://github.com/litestar-org/litestar/issues/357, https://github.com/litestar-org/litestar/pull/358
0.30.1¶
Released: 2025-01-20Bugfixes¶
- Using init db CLI command creates migrations directory in unexpected place#
When initializing migrations with the CLI, if no directory is specified, the directory from the configuration will be used.
References: https://github.com/litestar-org/litestar/issues/351, https://github.com/litestar-org/litestar/pull/354
0.30.0¶
Released: 2025-01-19Features¶
- refactored integration with CLI support#
Refactored the Starlette and FastAPI integration to support multiple configurations and sessions. Additionally, FastAPI will now have the database commands automatically registered with the FastAPI CLI.
References: https://github.com/litestar-org/litestar/pull/352
- reorganize Sanic extension#
The Sanic integration now aligns with the structure and idioms used in the other integrations.
References: https://github.com/litestar-org/litestar/pull/353
Bugfixes¶
- standardize on autocommit_include_redirect#
The flask plugin incorrectly used the term autocommit_with_redirect instead of the existing autocommit_include_redirect.
This changes makes the name consistent before we bump to a 1.x release
References: https://github.com/litestar-org/litestar/pull/349
- implement default schema serializer#
This corrects an issue that caused the Flask extension to use the incorrect serializer for encoding JSON
References: https://github.com/litestar-org/litestar/pull/350
0.29.1¶
Released: 2025-01-17Features¶
- add convenience hooks for to_model operations#
The service layer has always has a to_model function that accepts data and optionally an operation name. It would return a SQLAlchemy model no matter the input you gave it.
It is possible to move business logic into this to_model layer for populating fields on insert. (i.e. slug fields or tags, etc.).
When having logic for insert, update, delete, and upsert, that function can be a bit overwhelcoming. Now, there are helper functions that you can use that is specific to each DML hook:
to_model_on_create
to_model_on_update
to_model_on_delete
to_model_on_upsert
References: https://github.com/litestar-org/litestar/pull/347
0.29.0¶
Released: 2025-01-17Features¶
- various typing improvements for services#
Improved typing in the service layer and adds a additional type guards.
References: https://github.com/litestar-org/litestar/issues/261, https://github.com/litestar-org/litestar/pull/342
- Auto extend Flask CLI and add session integration#
The Advanced Alchemy alembic CLI is now auto-extended to your Flask application.
The Flask extension now also has a session handling middleware for handling auto-commits.
Last, but not least, there’s an experimental async portal that integrates a long running asyncio loop for running async operations in Flask. Using foo = portal.call(<async function>) you can get the result of an asynchronous function from a sync context.
References: https://github.com/litestar-org/litestar/pull/111
Bugfixes¶
- fully qualify all datetime module references#
All date time references are now full qualified to prevent any forward resolution issues with
from datetime import datetime
and
import datetime
References: https://github.com/litestar-org/litestar/pull/341
- disabled timezone in alembic.ini#
Disabled timezone in alembic.ini to fix alembic.util.exc.CommandError: Can’t locate timezone: UTC error while applying migrations
Reference: https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
References: https://github.com/litestar-org/litestar/pull/344
0.28.0¶
Released: 2025-01-13Features¶
- add bind-key option to CLI#
Adds a bind-key option to the Advance Alchemy CLI groups.
When present, the Alembic configs will be injected with the corresponding key.
References: https://github.com/litestar-org/litestar/pull/339
0.27.1¶
Released: 2025-01-11Bugfixes¶
- correction for 3.8 and 3.9 type hints#
Makes a few corrections to type hints in examples and tests to ensure 3.8 and 3.9 support
References: https://github.com/litestar-org/litestar/pull/330
0.27.0¶
Released: 2025-01-11Features¶
- add error_messages as class level configuration#
Exposes
error_messages
as a class level configuration in the repository and service classes.References: https://github.com/litestar-org/litestar/pull/315
- implement reusable CLI#
Exposes a reusable CLI for creating and updating releases. This can be used to extend any existing Click or Typer CLI.
References: https://github.com/litestar-org/litestar/pull/320
- adds additional type guard helpers#
Addition typing utilities to help with type checking and validation.
References: https://github.com/litestar-org/litestar/pull/322
0.26.0¶
Released: 2025-01-11Features¶
- AsyncAttrs & remove noload default#
This PR adds the AsyncAttrs to the default declarative bases for convenience.
It also changes the inherit_lazy_relationships == False behavior to use lazyload. SQLAlchemy will be deprecating noload in version 2.1
References: https://github.com/litestar-org/litestar/pull/305
- litestar DTO enhancements#
The Litestar DTO has been enhanced with: - The SQLAlchemyDTOConfig’s exclude, include, and rename_fields fields will now accept string or InstrumentedAttributes - DTO supports WriteOnlyMapped and DynamicMapped
References: https://github.com/litestar-org/litestar/issues/306, https://github.com/litestar-org/litestar/pull/310
- add default exception handler for litestar integration#
This adds a configuration option to automatically enable an exception handler for Repository errors.
This will update the exception handler if you do not have one already configured for the RepositoryException class
References: https://github.com/litestar-org/litestar/issues/275, https://github.com/litestar-org/litestar/pull/308
0.25.0¶
Released: 2025-01-11Features¶
- add max length for encrypted string#
The EncryptedString field now has the ability to validate against a set length.
References: https://github.com/litestar-org/litestar/pull/290
- AsyncAttrs & remove noload default#
This PR adds the AsyncAttrs to the default declarative bases for convenience.
It also changes the inherit_lazy_relationships == False behavior to use lazyload. SQLAlchemy will be deprecating noload in version 2.1
References: https://github.com/litestar-org/litestar/pull/305
0.24.0¶
Released: 2025-01-11Features¶
- remove lambda statement usage#
Removes the use of lambda statements in the repository and service classes. This has no change on the end user API, however, it should remove strange queries errors seen.
References: https://github.com/litestar-org/litestar/issues/286,, https://github.com/litestar-org/litestar/issues/287, https://github.com/litestar-org/litestar/pull/288
0.23.0¶
Released: 2025-01-11Features¶
- Improved typing of ModelDictT#
Fixes typing issues in service
https://github.com/litestar-org/advanced-alchemy/issues/265
This still doesn’t solve the problem of UnknownVariableType if the subtypes of ModelDictT are not installed (eg: Pydantic) But at least it solves the problem of incompatibilities when they are installed
References: https://github.com/litestar-org/litestar/pull/277
Bugfixes¶
- regression caused by conditional import Sequence for pagination.py#
Import Sequence directly from collections.abc Remove conditional import using TYPE_CHECKING Add noqa comment to suppress potential linter warnings
References: https://github.com/litestar-org/litestar/issues/272, https://github.com/litestar-org/litestar/pull/274
- make sure anyio is optional#
When running standalone or with a synchronous web framework, anyio is not required. This PR ensures that there are no module loading failures due to the missing import.
References: https://github.com/litestar-org/litestar/pull/278
0.22.0¶
Released: 2025-01-11Bugfixes¶
- CLI argument adjustment#
Changes the argument name so that it matches the name given in click.option.
References: https://github.com/litestar-org/litestar/pull/270
0.21.0¶
Released: 2025-01-11Features¶
- Dump all tables as JSON#
Adds a new CLI command to export tables to JSON. Similar to a Django dumpdata command.
References: https://github.com/litestar-org/litestar/pull/259
Bugfixes¶
- bind session to session class instead of to the session maker#
binds session into sanic extension as expected
in the original code, session maker was defined and then the dependency for session overwrites it with a session maker as the type. this seems non-ideal – you can’t get the session maker and when you ask for the session maker you get a session object
instead, this looks at the sessionmaker class_ property for adding the sanic dependency
References: https://github.com/litestar-org/litestar/issues/267, https://github.com/litestar-org/litestar/pull/268
- correct regex mappings for duplicate and foreign key errors#
Swap the variable names for DUPLICATE_KEY_REGEXES and FOREIGN_KEY_REGEXES to correctly match their contents. This ensures that the error detection for duplicate keys and foreign key violations works as intended across different database backends.
References: https://github.com/litestar-org/litestar/issues/262, https://github.com/litestar-org/litestar/pull/266
<=0.20.0¶
Released: 2025-01-11Bugfixes¶
- CollectionFilter returns all entries if values is empty#
Fixes #51
Bug: CollectionFilter returns all entries if values is empty
a simple 1=-1 is appended into the where clause when an empty list is passed into the in statement.
References: https://github.com/litestar-org/litestar/issues/51, https://github.com/litestar-org/litestar/pull/52
- better handle empty collection filters#
Currently, [this](https://github.com/cofin/litestar-fullstack/blob/main/src/app/lib/dependencies.py#L169) is how you can inject these filters in your app.
When using the id_filter dependency on it’s own, you have to have an additional not-null check before passing it into the repository.
This change handles that and allows you to pass in all filters into the repository function without checking their nullability.
References: https://github.com/litestar-org/litestar/pull/62
- service exists should use exists from repository#
The service should use the repository’s implementation of exists instead of a new one with a count.
References: https://github.com/litestar-org/litestar/pull/68
- do not set id with item_id when None#
This PR prevents the primary key from being overrwitten with None when using the service without the item_id parameter.
References: https://github.com/litestar-org/litestar/pull/67
- sqlalchemy dto for models non Column fields#
Examples of such fields are ColumnClause and Label, these are generated when using sqlalchemy.func
Fix SQLAlchemy dto generation for litestar when using models that have fields that are not instances of Column. Such fields arise from using expressions such as func.
References: https://github.com/litestar-org/litestar/pull/75