Skip to content

Conversation

YuanhengZ
Copy link

Description

As discussed in #4117, this looks like a re-export issue, I tried to re-export everything related directly from advanced_alchemy

Closes

Fix #4117

Deepwater added 5 commits May 5, 2025 09:39
This commit introduces a new module to re-export repository classes from `advanced_alchemy.repository`. It simplifies imports by allowing direct access via `litestar.plugins.sqlalchemy.repository`.
Introduce a module that re-exports the `wrap_sqlalchemy_exception` from `advanced_alchemy.exceptions`. This simplifies imports for users of `litestar.plugins.sqlalchemy`.
Consolidated and streamlined the `sqlalchemy.py` file by replacing verbose dynamic imports with explicit re-exports. The file now serves as a lightweight compatibility layer, deferring functionality to the new package structure.
Updated import paths from `litestar.plugins.sqlalchemy` to `advanced_alchemy` to resolve module resolution issues. The original paths referenced non-existent packages due to incorrect structure assumptions.
Introduces a new SQLAlchemy plugin module to streamline imports and maintain backward compatibility. Includes deprecation warnings for certain attributes, specifying their removal in version 3.0 and encouraging updated import paths.
@YuanhengZ YuanhengZ requested review from a team as code owners May 5, 2025 08:07
@github-actions github-actions bot added area/plugins This PR involves changes to the plugins size: small pr/external Triage Required 🏥 This requires triage labels May 5, 2025
@YuanhengZ YuanhengZ changed the title Fix re-export from litestar.plugins.sqlalchemy.repository fix: re-export from litestar.plugins.sqlalchemy.repository May 5, 2025
Copy link

codecov bot commented May 5, 2025

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 98.36%. Comparing base (3f8be84) to head (a7773c7).

Files with missing lines Patch % Lines
litestar/plugins/sqlalchemy/exceptions.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4163      +/-   ##
==========================================
- Coverage   98.38%   98.36%   -0.02%     
==========================================
  Files         348      351       +3     
  Lines       15889    15914      +25     
  Branches     1755     1757       +2     
==========================================
+ Hits        15632    15654      +22     
- Misses        121      124       +3     
  Partials      136      136              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Introduce tests to verify SQLAlchemy module imports, ensuring proper functionality and expected deprecation warnings. These tests validate direct imports, module redirections, and deprecated paths to maintain consistent behavior across interfaces.
Deepwater added 8 commits May 5, 2025 10:28
Replaced modern type hinting syntax with `List` and `Union` to pass mypy lint
Ensure files comply with standard formatting by adding a newline at the end. This resolves potential issues with certain tools or environments that require properly terminated files.
Eliminated the unnecessary assertion comparing ModelT between modules.
Adjusted the positioning of the module-level docstring to conform to formatting standards. This change ensures better readability and consistency with the project's style guidelines.
Adjusted the docstring in the SQLAlchemy
 exceptions module to a single-line
 format for improved readability.
 No functional changes were made to the module.
Reordered imports to follow standard conventions, ensuring better readability and maintainability. No functional changes were made to the code.
Updated whitespace and indentation in `test_sqlalchemy_imports.py` for better readability and adherence to style guidelines. These changes ensure consistent formatting, improving code maintainability and clarity without altering test behavior.
The `sqlalchemy.py` file was replaced by a package structure
@github-actions github-actions bot removed the area/plugins This PR involves changes to the plugins label May 5, 2025
@provinzkraut
Copy link
Member

@cofin can you take a look at this one? I'm actually not 100% sure what the intended functionality here is.

@YuanhengZ
Copy link
Author

You are creating multiple notifications for me, judging by the name, the above accounts belong to a single entity, can you refrain from breaking thoughts into multiple replies? I am waiting for evaluations from the team.

@litestar-org litestar-org deleted a comment May 10, 2025
@litestar-org litestar-org deleted a comment May 10, 2025
@litestar-org litestar-org deleted a comment May 10, 2025
@litestar-org litestar-org deleted a comment May 10, 2025
@litestar-org litestar-org deleted a comment May 10, 2025
@litestar-org litestar-org deleted a comment May 10, 2025
@euri10
Copy link
Contributor

euri10 commented May 10, 2025

You are creating multiple notifications for me, judging by the name, the above accounts belong to a single entity, can you refrain from breaking thoughts into multiple replies? I am waiting for evaluations from the team.

I deleted those comments and reported them as spam, sorry for the incovenience @YuanhengZ

@YuanhengZ
Copy link
Author

YuanhengZ commented May 11, 2025

You are creating multiple notifications for me, judging by the name, the above accounts belong to a single entity, can you refrain from breaking thoughts into multiple replies? I am waiting for evaluations from the team.

I deleted those comments and reported them as spam, sorry for the incovenience @YuanhengZ

Thank for the cleaning up!
No apologies needed, it is hardly your fault.

cofin added a commit to cofin/litestar that referenced this pull request Jun 29, 2025
This PR completes the deprecation and migration of SQLAlchemy functionality from `litestar.contrib.sqlalchemy` to `litestar.plugins.sqlalchemy`.

BREAKING CHANGE: `litestar.contrib.sqlalchemy` module has been completely removed. All imports must now use `litestar.plugins.sqlalchemy`.

Changes:
- Removed entire `litestar/contrib/sqlalchemy/` directory tree
- Updated all documentation examples to use new import paths
- Updated all tests to use new import paths
- Created proper submodule structure in `litestar/plugins/sqlalchemy/` with direct re-exports from `advanced_alchemy`
- Fixed type hint preservation for re-exported modules
- All functionality remains available through the new import structure

Migration:
- `from litestar.contrib.sqlalchemy import X` → `from litestar.plugins.sqlalchemy import X`
- `from litestar.contrib.sqlalchemy.plugins import Y` → `from litestar.plugins.sqlalchemy import Y`

Related PRs:
- litestar-org#4069 - Initial attempt by @provinzkraut
- litestar-org#4163 - Second attempt by @cofin
- litestar-org#3755 - Original deprecation PR

Closes litestar-org#4069
Closes litestar-org#4163

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
cofin added a commit to cofin/litestar that referenced this pull request Jun 29, 2025
This PR completes the deprecation and migration of SQLAlchemy functionality from `litestar.contrib.sqlalchemy` to `litestar.plugins.sqlalchemy`.

BREAKING CHANGE: `litestar.contrib.sqlalchemy` module has been completely removed. All imports must now use `litestar.plugins.sqlalchemy`.

Changes:
- Removed entire `litestar/contrib/sqlalchemy/` directory tree
- Updated all documentation examples to use new import paths
- Updated all tests to use new import paths
- Created proper submodule structure in `litestar/plugins/sqlalchemy/` with direct re-exports from `advanced_alchemy`
- Fixed type hint preservation for re-exported modules
- All functionality remains available through the new import structure

Migration:
- `from litestar.contrib.sqlalchemy import X` → `from litestar.plugins.sqlalchemy import X`
- `from litestar.contrib.sqlalchemy.plugins import Y` → `from litestar.plugins.sqlalchemy import Y`

Related PRs:
- litestar-org#4069 - Initial attempt by @provinzkraut
- litestar-org#4163 - Second attempt by @cofin
- litestar-org#3755 - Original deprecation PR

Closes litestar-org#4069
Closes litestar-org#4163

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
cofin added a commit to cofin/litestar that referenced this pull request Sep 27, 2025
…alchemy imports

BREAKING CHANGE: All SQLAlchemy functionality has been removed from Litestar.
Both litestar.contrib.sqlalchemy and litestar.plugins.sqlalchemy modules have
been completely removed. Users must now import directly from advanced-alchemy.

Migration:
- from litestar.contrib.sqlalchemy import X → from advanced_alchemy.extensions.litestar import X
- from litestar.plugins.sqlalchemy import Y → from advanced_alchemy.extensions.litestar import Y

This completes the separation of concerns, with advanced-alchemy being the
sole provider of SQLAlchemy integration for Litestar.

Changes:
- Removed entire litestar/contrib/sqlalchemy/ directory tree
- Removed litestar/plugins/sqlalchemy.py re-export file
- Updated all documentation examples to use new import paths
- Updated all tests to use new import paths
- Deleted tests for deprecated functionality
- Added changelog entry explaining the breaking change

Related to:
- litestar-org#4225 - Previous near-perfect implementation
- litestar-org#4069, litestar-org#4163 - Earlier attempts
- litestar-org#3755 - Original deprecation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Broken re-export from litestar.plugins.sqlalchemy.repository
3 participants