Sanitize autoentity-generated names to prevent invalid REST paths and GraphQL singular/plural tables for SQL objects with spaces#3609
Open
Copilot wants to merge 7 commits into
Open
Conversation
Agent-Logs-Url: https://github.com/Azure/data-api-builder/sessions/2051de6a-3432-4bd6-901c-3a3d6a8cc114 Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix invalid REST paths generated for tables with spaces
Sanitize autoentity-generated names to prevent invalid REST paths for SQL objects with spaces
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves MSSQL autoentity generation by sanitizing auto-generated entity names so SQL objects containing whitespace don’t produce invalid REST path segments or invalid GraphQL names during default singular/plural generation and config validation.
Changes:
- Add a whitespace-removal (camel-join) sanitizer for generated entity names and apply it during MSSQL autoentity generation.
- Extend MSSQL test schema with a table that contains spaces in its name and seed data for it.
- Update configuration tests to validate REST + GraphQL access for an autoentity generated from an object with spaces.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Service.Tests/DatabaseSchema-MsSql.sql | Adds an MSSQL table with whitespace in its name to exercise autoentity naming. |
| src/Service.Tests/Configuration/ConfigurationTests.cs | Extends autoentity end-to-end test to include an object with spaces and validates REST/GraphQL access. |
| src/Core/Services/MetadataProviders/SqlMetadataProvider.cs | Introduces SanitizeGeneratedEntityName helper for generated entity names. |
| src/Core/Services/MetadataProviders/MsSqlMetadataProvider.cs | Applies sanitization to autoentity-generated entityName before entity creation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why make this change?
Tables with whitespace in names (for example,
Order Items) were being auto-generated into entity names likedbo_Order Items, which then produced invalid REST paths as well as invalid GraphQL names for singular/plural tables which failed config validation. This change ensures autoentity name generation does not pass whitespace through to REST path and GraphQL singular/plural tables defaults.{schema}/{object}verbatim; whitespace in object names breaksdab validate.What is this change?
SqlMetadataProviderand applied it to generatedentity_namebefore entity creation.dbo_Order Items→dbo_OrderItems.TestAutoentitiesGeneratedWithUnusualElementson theConfigurationTestsfile with cases for single/multiple spaces.How was this tested?
Sample Request(s)
dab auto-config add mydef --patterns.include "dbo.Order Items" --patterns.name "{schema}_{object}"dab validatedbo.[Order Items]dbo_OrderItems(no whitespace)