feat: add query endpoint with WHERE clause parsing (#6) #90
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.
Summary
Implements Issue #6 - Query endpoint with WHERE clause parsing for the FeatureServer API.
This PR adds comprehensive query functionality including:
Key Features
Endpoints
GET /rest/services/{serviceId}/FeatureServer/{layerId}/queryPOST /rest/services/{serviceId}/FeatureServer/{layerId}/queryQuery Parameters
where- WHERE clause for attribute filteringoutFields- Comma-separated list of fields to return (supports "*")returnGeometry- Boolean to control geometry inclusionf- Output format (json, geojson)resultOffset- Pagination offsetresultRecordCount- Maximum results to returnSecurity
Response Format
Compliant Esri FeatureServer JSON format:
{ "objectIdFieldName": "objectid", "features": [...], "exceededTransferLimit": false }Test Coverage
Added 8 comprehensive integration tests covering:
QueryFeatures_WithValidWhereClause_ReturnsFilteredFeatures)QueryFeatures_WithSqlInjectionAttempt_Returns400)QueryFeatures_WithInvalidWhereClause_Returns400)QueryFeatures_WithOutFields_ReturnsOnlySpecifiedFields)QueryFeatures_WithReturnGeometryFalse_ReturnsNoGeometry)QueryFeatures_WithNonExistentService_Returns404)QueryFeatures_WithNonExistentLayer_Returns404)QueryFeatures_WithPostRequest_ReturnsFilteredFeatures)All tests pass with proper error messages and status codes.
Files Modified
Core Implementation
src/Honua.Server/Features/FeatureServer/FeatureServerEndpoints.cs- Query endpointssrc/Honua.Server/Features/FeatureServer/Models/FeatureServerModels.cs- Query modelssrc/Honua.Server/Features/FeatureServer/FeatureServerLog.cs- Structured loggingTesting Infrastructure
tests/Honua.TestKit/Infrastructure/TestFeatureStore.cs- Test implementationtests/Honua.Server.Tests/FeatureServerEndpointTests.cs- Integration testsTechnical Details
Parameter Binding Fix
Fixed HTTP GET parameter binding by using individual
[FromQuery]parameters instead of[AsParameters]with a complex object, ensuring proper query string parameter mapping.Error Handling
Security Implementation
TestFeatureStore includes basic WHERE clause validation:
Test Results
All existing tests continue to pass, ensuring no regressions.
🤖 Generated with Claude Code