.Net: [MEVD] Ensure identifiers are properly quoted#13470
Merged
roji merged 1 commit intomicrosoft:mainfrom Jan 27, 2026
Merged
.Net: [MEVD] Ensure identifiers are properly quoted#13470roji merged 1 commit intomicrosoft:mainfrom
roji merged 1 commit intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens escaping and validation of user-defined identifiers across multiple vector store connectors (.NET), and updates tests to reflect the safer SQL/GraphQL/Cosmos query shapes. The goal is to ensure schema, table, column, and JSON field names are always either safely quoted/escaped or proactively validated where escaping isn’t possible.
Changes:
- PostgreSQL, SQLite, and SQL Server vector connectors now consistently quote and escape schema, table, column, and index identifiers via dedicated helpers, with tests updated accordingly.
- Cosmos DB NoSQL queries and filters now use bracket notation with proper JSON-style escaping for property names, and related tests are updated to assert the new query shape.
- Weaviate, Redis, and Azure AI Search model builders now validate storage names against backend-specific identifier rules (GraphQL, RediSearch, OData), and filter/query builders rely on validated identifiers.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
dotnet/test/VectorData/PgVector.UnitTests/PostgresSqlBuilderTests.cs |
Updates expectations for schema/table quoting and index creation so that schema ("public") is quoted consistently with the table and column identifiers. |
dotnet/test/VectorData/CosmosNoSql.UnitTests/CosmosNoSqlCollectionQueryBuilderTests.cs |
Adjusts expected Cosmos DB SQL strings to use x["..."] bracket notation and to match the new escaped property access patterns in SELECT, WHERE, ORDER BY, and SELECT TOP queries. |
dotnet/src/VectorData/Weaviate/WeaviateQueryBuilder.cs |
Ensures Weaviate GraphQL sort paths are JSON-encoded strings while relying on validated storage names, improving robustness of sort: [ { path: [...] }] clauses. |
dotnet/src/VectorData/Weaviate/WeaviateModelBuilder.cs |
Adds ValidateProperty logic enforcing GraphQL name rules for storage names (first char letter/underscore; subsequent alphanumeric/underscore), throwing clear errors when invalid. |
dotnet/src/VectorData/SqliteVec/SqliteCommandBuilder.cs |
Replaces ad-hoc string interpolation with AppendIdentifier/QuoteIdentifier helpers for all table/column/index names and joins, ensuring SQLite identifiers are consistently double-quoted and escaped. |
dotnet/src/VectorData/SqliteVec/SqliteCollection.cs |
Stops pre-escaping table names on construction and instead passes raw names into SqliteCommandBuilder, avoiding double-escaping now that builder methods quote/escape identifiers themselves. |
dotnet/src/VectorData/SqlServer/SqlServerCommandBuilder.cs |
Centralizes SQL Server identifier quoting into AppendIdentifier, applies it for columns, primary keys, indexes, merge statements, DELETE/SELECT queries, and ORDER BY clauses to prevent malformed or injectable names. |
dotnet/src/VectorData/Redis/RedisModelBuilder.cs |
Introduces ValidateStorageName / IsValidIdentifier to enforce RediSearch-safe field names during model building, rejecting invalid storage names early. |
dotnet/src/VectorData/Redis/RedisJsonModelBuilder.cs |
Hooks Redis JSON model building into RedisModelBuilder.ValidateStorageName so JSON-backed collections share the same RediSearch field-name validation. |
dotnet/src/VectorData/Redis/RedisFilterTranslator.cs |
Documents that Redis field names are assumed validated at model-build time and keeps filter generation using property.StorageName with that guarantee. |
dotnet/src/VectorData/PgVector/PostgresSqlBuilder.cs |
Refactors SQL construction to consistently use AppendIdentifier for schema/table/column/index names across CREATE TABLE/INDEX, UPSERT, SELECT, DELETE, and nearest-neighbor search queries, including legacy filter support. |
dotnet/src/VectorData/CosmosNoSql/CosmosNoSqlFilterTranslator.cs |
Changes filter property access to use x["..."] bracket notation with escaping of backslashes and double quotes in storage names. |
dotnet/src/VectorData/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs |
Centralizes Cosmos JSON property escaping via EscapeJsonPropertyName/GeneratePropertyAccess, and updates all SELECT/WHERE/ORDER BY construction to use bracket notation with proper escaping. |
dotnet/src/VectorData/AzureAISearch/AzureAISearchModelBuilder.cs |
Adds OData identifier validation for storage names, enforcing the same naming constraints as the OData spec and throwing with a clear message when they are violated. |
dotnet/src/VectorData/AzureAISearch/AzureAISearchFilterTranslator.cs |
Documents reliance on prevalidated OData identifiers when emitting property names in filter expressions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
westey-m
approved these changes
Jan 26, 2026
markwallace-microsoft
approved these changes
Jan 26, 2026
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.
Closes #12161