Skip to content

.Net: Bug: Postgres SQL syntax error #11274

@dluc

Description

@dluc

Some input validation is missing, leading to syntax errors in the SQL generated.

Syntax errors could be avoided using named parameters (e.g. "@paramname").

This specific error could be avoided validating the model definition and informing the user with a specific validation exception. For instance, here the vector column is missing:

var def = new VectorStoreRecordDefinition
{
    Properties = new List<VectorStoreRecordProperty>
    {
        new VectorStoreRecordKeyProperty("Id", typeof(string)),
        new VectorStoreRecordDataProperty("Count", typeof(long))
    }
};

var collection = db.GetCollection<string, VectorStoreGenericDataModel<string>>("tests", def);
await collection.CreateCollectionAsync().ConfigureAwait(false);

var record = new VectorStoreGenericDataModel<string>("1");
record.Vectors["Count"] = 123;
await collection.UpsertAsync(record);

leading to this generic/proprietary exception:

Microsoft.Extensions.VectorData.VectorStoreOperationException: Call to vector store failed.
---> Npgsql.PostgresException (0x80004005): 42601: syntax error at or near ";"

Metadata

Metadata

Assignees

Labels

.NETIssue or Pull requests regarding .NET codeBuildFeatures planned for next Build conferencebugSomething isn't workingmsft.ext.vectordataRelated to Microsoft.Extensions.VectorData

Type

Projects

Status

Sprint: Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions