Fix of issue with distinct queries in read queries #491
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.
Pull Request Description: Fix of Issue with Distinct Queries in Read Queries
This pull request addresses a critical issue related to executing distinct queries in our read operations. The changes made improve the handling of fetch queries in the
read_query
andread_multi_query
methods within thedatabase_operations.py
file.Motivation
Previously, distinct queries could lead to inconsistent results or errors due to inadequate handling of query execution results, particularly when dealing with single-column outputs. By enhancing the logic for processing results from SQLAlchemy, we ensure that our queries return the expected data structure, whether that be scalars, dictionaries, or ORM objects. This change directly improves the robustness of our database operations, ensuring that applications relying on these queries behave correctly.
Key Improvements
scalars()
and ensuring that multiple-column results are correctly formatted as dictionaries./database/get-list-of-distinct-records
) has been introduced to demonstrate the execution of distinct queries effectively. This endpoint includes logic to insert multiple records and query distinct values, providing a practical example for users.read_query
andread_multi_query
methods have been revised to clarify expected input and output, enhancing usability for developers.Coverage and Testing
Changes have been made to the coverage reports, reflecting adjustments in the codebase. The coverage badge has been updated to show the current coverage percentage, ensuring transparency for contributors regarding the project's test coverage.
By merging this pull request, we enhance the overall functionality and reliability of our database interactions, providing a better experience for developers working with distinct queries in our application.