Skip to content

Fix: Fixed sql alchemy sort mixin#32

Merged
HosseinNejatiJavaremi merged 1 commit intoSyntaxArc:masterfrom
miladmahmoodi:fix-sort-query
Apr 16, 2025
Merged

Fix: Fixed sql alchemy sort mixin#32
HosseinNejatiJavaremi merged 1 commit intoSyntaxArc:masterfrom
miladmahmoodi:fix-sort-query

Conversation

@miladmahmoodi
Copy link
Copy Markdown
Contributor

Description

This change fixes an issue in the SqlAlchemySortMixin class where the sorting logic did not properly handle SortOrderType when it was provided as an Enum. The original code assumed sort_info.order was a string and directly compared it to SortOrderType.ASCENDING, which caused incorrect sorting behavior when an Enum was passed. The updated code extracts the value from the Enum (if applicable) and compares it against the value of SortOrderType.ASCENDING and SortOrderType.DESCENDING. Additionally, it introduces explicit error handling for invalid sort_info.order values by raising an InvalidArgumentError.

This fix ensures that sorting works correctly regardless of whether sort_info.order is passed as a string or an Enum, improving robustness and reliability of the sorting functionality.

Fixes # (Sorting issue with Enum-based SortOrderType in SqlAlchemySortMixin)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Additional context

The change was motivated by bug reports indicating that sorting failed when SortOrderType was passed as an Enum in certain API endpoints. The fix maintains backward compatibility with string-based inputs while adding support for Enum-based inputs and improving error handling.

@HosseinNejatiJavaremi HosseinNejatiJavaremi merged commit efea247 into SyntaxArc:master Apr 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants