fix: replace is_() with == in dataset name filter #3983
Merged
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.
This pull request addresses a syntax error occurring in the
list_datasets
function when filtering datasets by name, specifically when using PostgreSQL 16.Issue
When querying the
/v1/datasets
endpoint with PostgreSQL 16, the function encounters a syntax error. The error occurs due to the use of SQLAlchemy'sis_()
method for comparing the dataset name, which is typically used for NULL comparisons. This resulted in a PostgreSQL syntax error near "$1" when the query was executed.Error logs revealed:
This error indicates that PostgreSQL 16 is not interpreting the
IS
operator correctly with the parameter placeholder$1
.Fix
Changed the dataset name filter from:
to:
Rationale
According to the SQLAlchemy documentation, the
is_()
method is meant for NULL comparisons and generates SQL using the IS operator. For value equality comparisons, the==
operator should be used instead. This change ensures compatibility with PostgreSQL 16 and correctly generates the SQL for name comparison.Impact
This change resolves the SQL syntax error and allows proper filtering of datasets by name when using PostgreSQL 16. It ensures that the
/v1/datasets
endpoint functions correctly with parameter-based filtering.Related documentation:
SQLAlchemy ColumnOperators.is_(): https://docs.sqlalchemy.org/en/20/core/sqlelement.html#sqlalchemy.sql.expression.ColumnOperators.is_