feat: fix SQLAlchemy 2.x compatibility in row iteration#4
Merged
Conversation
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dependency conflict with SQLAlchemy version
Fix SQLAlchemy 2.x compatibility in row iteration
Nov 14, 2025
|
@copilot fix failed CI linter: https://github.com/officialpycasbin/casbin-databases-adapter/actions/runs/19370124141/job/55424203749 remove the file: test_compatibility.py |
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Contributor
Author
Fixed in commit 92699be:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix SQLAlchemy Version Conflict ✅
Problem Statement
The package previously pinned
SQLAlchemy==1.4.42anddatabases==0.7.0, causing dependency conflicts when trying to use the adapter alongside packages that require SQLAlchemy 2.x, such assqlmodel>=0.0.27.Solution Summary
Changes Made
1. Code Changes (
adapter.py)Changed
row._mapping.items()todict(row._mapping).items()in two methods:load_policy()- Line 32load_filtered_policy()- Line 87Why this change? In SQLAlchemy 2.x with databases>=0.8.0, accessing
.itemsdirectly onrow._mappinggoes through__getattr__which tries to look it up as a column name. Usingdict()conversion works with both versions.2. Dependency Updates
requirements.txt: RelaxedSQLAlchemy==1.4.42→SQLAlchemy>=1.4.42requirements.txt: Relaxeddatabases==0.7.0→databases>=0.7.0requirements-test.txt: Applied same version range updates3. Code Formatting
4. Build Configuration
.gitignoreto exclude Python build artifacts (*.egg-info, dist/, build/)Compatibility Matrix
Verification
Minimal Impact
Only 2 lines of code changed in the adapter, ensuring minimal risk and maintaining existing behavior.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.