Skip to content

Conversation

@feordin
Copy link
Contributor

@feordin feordin commented Dec 19, 2025

Description

Updates SQL generator to handle multiple target types for ReferenceSearchParam.

Related issues

Addresses [issue AB#177046].

Testing

Describe how this change was tested.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

@feordin feordin added this to the FY26\Q2\2Wk\2Wk13 milestone Dec 19, 2025
@feordin feordin added the Bug-Performance Performance related bugs. label Dec 19, 2025
@feordin feordin requested a review from a team as a code owner December 19, 2025 01:56
@feordin feordin added Area-SQL Area related to the SQL Server data provider Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs labels Dec 19, 2025
ResourceVersionTypes = ResourceVersionType.Latest,
};

var output = _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
output
is useless, since its value is never read.

Copilot Autofix

AI 19 days ago

In general, to fix a "useless assignment to local variable" where you still need the side effect of the right-hand side, you remove the unused local variable and keep just the expression statement (method call). If you do not need the side effect either, you remove the entire statement.

Here, the test clearly needs to execute _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions) to populate _strBuilder, because generatedSql is read from _strBuilder immediately afterward. However, the variable output is never used. The best fix is therefore to remove the var output = part and keep the method call as a standalone statement. This preserves all existing behavior and cleans up the unused assignment.

Concretely, in src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlQueryGeneratorTests.cs, replace the line:

185:         var output = _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);

with:

185:         _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);

No additional methods, imports, or definitions are needed.

Suggested changeset 1
src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlQueryGeneratorTests.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlQueryGeneratorTests.cs b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlQueryGeneratorTests.cs
--- a/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlQueryGeneratorTests.cs
+++ b/src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlQueryGeneratorTests.cs
@@ -182,7 +182,7 @@
             ResourceVersionTypes = ResourceVersionType.Latest,
         };
 
-        var output = _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);
+        _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);
 
         string generatedSql = _strBuilder.ToString();
 
EOF
@@ -182,7 +182,7 @@
ResourceVersionTypes = ResourceVersionType.Latest,
};

var output = _queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);
_queryGenerator.VisitSqlRoot(sqlExpression, searchOptions);

string generatedSql = _strBuilder.ToString();

Copilot is powered by AI and may make mistakes. Always verify output.
@feordin
Copy link
Contributor Author

feordin commented Jan 5, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-SQL Area related to the SQL Server data provider Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Bug-Performance Performance related bugs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants