-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathSqlServerCommandBuilderTests.cs
More file actions
613 lines (525 loc) · 22.8 KB
/
SqlServerCommandBuilderTests.cs
File metadata and controls
613 lines (525 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
// Copyright (c) Microsoft. All rights reserved.
using System.Text;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlTypes;
using Microsoft.Extensions.VectorData;
using Microsoft.Extensions.VectorData.ProviderServices;
using Microsoft.SemanticKernel.Connectors.SqlServer;
using Xunit;
namespace SqlServer.ConformanceTests;
public class SqlServerCommandBuilderTests
{
[Theory]
[InlineData("schema", "name", "[schema].[name]")]
[InlineData(null, "name", "[name]")]
[InlineData("schema", "[brackets]", "[schema].[[brackets]]]")]
[InlineData(null, "[needsEscaping]", "[[needsEscaping]]]")]
[InlineData("needs]escaping", "[brackets]", "[needs]]escaping].[[brackets]]]")]
public void AppendTableName(string? schema, string table, string expectedFullName)
{
StringBuilder result = new();
SqlServerCommandBuilder.AppendTableName(result, schema, table);
Assert.Equal(expectedFullName, result.ToString());
}
[Theory]
[InlineData("name", "@name_")] // typical name
[InlineData("na me", "@na_")] // contains a whitespace, an illegal parameter name character
[InlineData("123", "@_")] // starts with a digit, also not allowed
[InlineData("ĄŻŚĆ_doesNotStartWithAscii", "@_")] // starts with a non-ASCII character
public void AppendParameterName(string propertyName, string expectedPrefix)
{
StringBuilder builder = new();
StringBuilder expectedBuilder = new();
KeyPropertyModel keyProperty = new(propertyName, typeof(string));
int paramIndex = 0; // we need a dedicated variable to ensure that AppendParameterName increments the index
for (int i = 0; i < 10; i++)
{
Assert.Equal(paramIndex, i);
SqlServerCommandBuilder.AppendParameterName(builder, keyProperty, ref paramIndex, out string parameterName);
Assert.Equal($"{expectedPrefix}{i}", parameterName);
expectedBuilder.Append(parameterName);
}
Assert.Equal(expectedBuilder.ToString(), builder.ToString());
}
[Theory]
[InlineData("schema", "simpleName", "[simpleName]")]
[InlineData("schema", "[needsEscaping]", "[[needsEscaping]]]")]
public void DropTable(string schema, string table, string expectedTable)
{
using SqlConnection connection = CreateConnection();
using SqlCommand command = SqlServerCommandBuilder.DropTableIfExists(connection, schema, table);
Assert.Equal($"DROP TABLE IF EXISTS [{schema}].{expectedTable}", command.CommandText);
}
[Theory]
[InlineData("schema", "simpleName")]
[InlineData("schema", "[needsEscaping]")]
public void SelectTableName(string schema, string table)
{
using SqlConnection connection = CreateConnection();
using SqlCommand command = SqlServerCommandBuilder.SelectTableName(connection, schema, table);
Assert.Equal(
"""
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND (@schema is NULL or TABLE_SCHEMA = @schema)
AND TABLE_NAME = @tableName
"""
, command.CommandText);
Assert.Equal(schema, command.Parameters[0].Value);
Assert.Equal(table, command.Parameters[1].Value);
}
[Fact]
public void SelectTableNames()
{
const string SchemaName = "theSchemaName";
using SqlConnection connection = CreateConnection();
using SqlCommand command = SqlServerCommandBuilder.SelectTableNames(connection, SchemaName);
Assert.Equal(
"""
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND (@schema is NULL or TABLE_SCHEMA = @schema)
"""
, command.CommandText);
Assert.Equal(SchemaName, command.Parameters[0].Value);
Assert.Equal("@schema", command.Parameters[0].ParameterName);
}
[Theory]
[InlineData(true)]
[InlineData(false)]
public void CreateTable(bool ifNotExists)
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("simpleName", typeof(string)),
new VectorStoreDataProperty("with space", typeof(int)) { IsIndexed = true },
new VectorStoreDataProperty("nullableInt", typeof(int?)),
new VectorStoreDataProperty("flag", typeof(bool)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10),
new VectorStoreVectorProperty("nullableEmbedding", typeof(ReadOnlyMemory<float>?), 10)
]);
using SqlConnection connection = CreateConnection();
var commands = SqlServerCommandBuilder.CreateTable(connection, "schema", "table", ifNotExists, model);
var command = Assert.Single(commands);
string expectedCommand =
"""
BEGIN
CREATE TABLE [schema].[table] (
[id] BIGINT IDENTITY,
[simpleName] NVARCHAR(MAX),
[with space] INT NOT NULL,
[nullableInt] INT,
[flag] BIT NOT NULL,
[embedding] VECTOR(10) NOT NULL,
[nullableEmbedding] VECTOR(10),
PRIMARY KEY ([id])
);
CREATE INDEX index_table_withspace ON [schema].[table]([with space]);
END;
""";
if (ifNotExists)
{
expectedCommand = "IF OBJECT_ID(N'[schema].[table]', N'U') IS NULL" + Environment.NewLine + expectedCommand;
}
Assert.Equal(expectedCommand, command.CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void CreateTable_WithDiskAnnIndex()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10)
{
IndexKind = IndexKind.DiskAnn,
DistanceFunction = DistanceFunction.CosineDistance
}
]);
using SqlConnection connection = CreateConnection();
var commands = SqlServerCommandBuilder.CreateTable(connection, "schema", "table", ifNotExists: false, model);
Assert.Equal(3, commands.Count);
Assert.Equal(
"""
BEGIN
CREATE TABLE [schema].[table] (
[id] BIGINT IDENTITY,
[name] NVARCHAR(MAX),
[embedding] VECTOR(10) NOT NULL,
PRIMARY KEY ([id])
);
END;
""", commands[0].CommandText, ignoreLineEndingDifferences: true);
Assert.Equal("ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON;", commands[1].CommandText);
Assert.Equal(
"""
CREATE VECTOR INDEX index_table_embedding ON [schema].[table]([embedding]) WITH (METRIC = 'COSINE', TYPE = 'DISKANN');
""", commands[2].CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void CreateTable_WithDiskAnnIndex_EuclideanDistance()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10)
{
IndexKind = IndexKind.DiskAnn,
DistanceFunction = DistanceFunction.EuclideanDistance
}
]);
using SqlConnection connection = CreateConnection();
var commands = SqlServerCommandBuilder.CreateTable(connection, "schema", "table", ifNotExists: false, model);
Assert.Equal(3, commands.Count);
Assert.Equal(
"""
BEGIN
CREATE TABLE [schema].[table] (
[id] BIGINT IDENTITY,
[embedding] VECTOR(10) NOT NULL,
PRIMARY KEY ([id])
);
END;
""", commands[0].CommandText, ignoreLineEndingDifferences: true);
Assert.Equal("ALTER DATABASE SCOPED CONFIGURATION SET PREVIEW_FEATURES = ON;", commands[1].CommandText);
Assert.Equal(
"""
CREATE VECTOR INDEX index_table_embedding ON [schema].[table]([embedding]) WITH (METRIC = 'EUCLIDEAN', TYPE = 'DISKANN');
""", commands[2].CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void CreateTable_WithUnsupportedIndexKind_Throws()
{
Assert.Throws<NotSupportedException>(() =>
BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10)
{
IndexKind = IndexKind.Hnsw
}
]));
}
[Fact]
public void SelectVector_WithDiskAnnIndex()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 3)
{
IndexKind = IndexKind.DiskAnn,
DistanceFunction = DistanceFunction.CosineDistance
}
]);
using SqlConnection connection = CreateConnection();
var options = new VectorSearchOptions<Dictionary<string, object?>> { IncludeVectors = true };
using SqlCommand command = SqlServerCommandBuilder.SelectVector(
connection, "schema", "table",
model.VectorProperties[0], model,
top: 5, options,
new SqlVector<float>(new float[] { 1f, 2f, 3f }));
Assert.Equal(
"""
SELECT TOP(5) WITH APPROXIMATE t.[id],t.[name],t.[embedding],
s.[distance] AS [score]
FROM VECTOR_SEARCH(TABLE = [schema].[table] AS t, COLUMN = [embedding], SIMILAR_TO = @vector, METRIC = 'COSINE') AS s
ORDER BY [score] ASC
""", command.CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void SelectVector_WithDiskAnnIndex_WithSkip()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 3)
{
IndexKind = IndexKind.DiskAnn,
DistanceFunction = DistanceFunction.CosineDistance
}
]);
using SqlConnection connection = CreateConnection();
var options = new VectorSearchOptions<Dictionary<string, object?>> { IncludeVectors = false, Skip = 3 };
using SqlCommand command = SqlServerCommandBuilder.SelectVector(
connection, "schema", "table",
model.VectorProperties[0], model,
top: 5, options,
new SqlVector<float>(new float[] { 1f, 2f, 3f }));
Assert.Equal(
"""
SELECT * FROM (SELECT TOP(8) WITH APPROXIMATE t.[id],t.[name],
s.[distance] AS [score]
FROM VECTOR_SEARCH(TABLE = [schema].[table] AS t, COLUMN = [embedding], SIMILAR_TO = @vector, METRIC = 'COSINE') AS s
ORDER BY [score] ASC
) AS [inner]
ORDER BY [score] ASC
OFFSET 3 ROWS FETCH NEXT 5 ROWS ONLY;
""", command.CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void SelectVector_WithDiskAnnIndex_WithFilter()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 3)
{
IndexKind = IndexKind.DiskAnn,
DistanceFunction = DistanceFunction.CosineDistance
}
]);
using SqlConnection connection = CreateConnection();
var options = new VectorSearchOptions<Dictionary<string, object?>>
{
Filter = d => (string)d["name"]! == "test"
};
using SqlCommand command = SqlServerCommandBuilder.SelectVector(
connection, "schema", "table",
model.VectorProperties[0], model,
top: 5, options,
new SqlVector<float>(new float[] { 1f, 2f, 3f }));
Assert.Equal(
"""
SELECT TOP(5) WITH APPROXIMATE t.[id],t.[name],
s.[distance] AS [score]
FROM VECTOR_SEARCH(TABLE = [schema].[table] AS t, COLUMN = [embedding], SIMILAR_TO = @vector, METRIC = 'COSINE') AS s
WHERE (t.[name] = 'test')
ORDER BY [score] ASC
""", command.CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void SelectVector_WithDiskAnnIndex_WithScoreThreshold()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 3)
{
IndexKind = IndexKind.DiskAnn,
DistanceFunction = DistanceFunction.CosineDistance
}
]);
using SqlConnection connection = CreateConnection();
var options = new VectorSearchOptions<Dictionary<string, object?>>
{
IncludeVectors = true,
ScoreThreshold = 0.5f
};
using SqlCommand command = SqlServerCommandBuilder.SelectVector(
connection, "schema", "table",
model.VectorProperties[0], model,
top: 5, options,
new SqlVector<float>(new float[] { 1f, 2f, 3f }));
Assert.Equal(
"""
SELECT TOP(5) WITH APPROXIMATE t.[id],t.[name],t.[embedding],
s.[distance] AS [score]
FROM VECTOR_SEARCH(TABLE = [schema].[table] AS t, COLUMN = [embedding], SIMILAR_TO = @vector, METRIC = 'COSINE') AS s
WHERE s.[distance] <= @scoreThreshold
ORDER BY [score] ASC
""", command.CommandText, ignoreLineEndingDifferences: true);
}
[Fact]
public void Upsert()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)) { IsAutoGenerated = false },
new VectorStoreDataProperty("simpleString", typeof(string)),
new VectorStoreDataProperty("simpleInt", typeof(int)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10)
]);
Dictionary<string, object?>[] records =
[
new Dictionary<string, object?>
{
{ "id", 0L },
{ "simpleString", "nameValue0" },
{ "simpleInt", 134 },
{ "embedding", new ReadOnlyMemory<float>([10.0f]) }
},
new Dictionary<string, object?>
{
{ "id", 1L },
{ "simpleString", "nameValue1" },
{ "simpleInt", 135 },
{ "embedding", new ReadOnlyMemory<float>([11.0f]) }
}
];
using SqlConnection connection = CreateConnection();
using SqlCommand command = connection.CreateCommand();
Assert.True(SqlServerCommandBuilder.Upsert<long>(command, "schema", "table", model, records, firstRecordIndex: 0, generatedEmbeddings: null));
string expectedCommand =
""""
MERGE INTO [schema].[table] AS t
USING (VALUES (@id_0,@simpleString_1,@simpleInt_2,@embedding_3)) AS s ([id],[simpleString],[simpleInt],[embedding])
ON (t.[id] = s.[id])
WHEN MATCHED THEN
UPDATE SET t.[simpleString] = s.[simpleString],t.[simpleInt] = s.[simpleInt],t.[embedding] = s.[embedding]
WHEN NOT MATCHED THEN
INSERT ([id],[simpleString],[simpleInt],[embedding])
VALUES (s.[id],s.[simpleString],s.[simpleInt],s.[embedding])
OUTPUT inserted.[id];
MERGE INTO [schema].[table] AS t
USING (VALUES (@id_4,@simpleString_5,@simpleInt_6,@embedding_7)) AS s ([id],[simpleString],[simpleInt],[embedding])
ON (t.[id] = s.[id])
WHEN MATCHED THEN
UPDATE SET t.[simpleString] = s.[simpleString],t.[simpleInt] = s.[simpleInt],t.[embedding] = s.[embedding]
WHEN NOT MATCHED THEN
INSERT ([id],[simpleString],[simpleInt],[embedding])
VALUES (s.[id],s.[simpleString],s.[simpleInt],s.[embedding])
OUTPUT inserted.[id];
"""";
Assert.Equal(expectedCommand, command.CommandText, ignoreLineEndingDifferences: true);
for (int i = 0; i < records.Length; i++)
{
Assert.Equal($"@id_{4 * i + 0}", command.Parameters[4 * i + 0].ParameterName);
Assert.Equal((long)i, command.Parameters[4 * i + 0].Value);
Assert.Equal($"@simpleString_{4 * i + 1}", command.Parameters[4 * i + 1].ParameterName);
Assert.Equal($"nameValue{i}", command.Parameters[4 * i + 1].Value);
Assert.Equal($"@simpleInt_{4 * i + 2}", command.Parameters[4 * i + 2].ParameterName);
Assert.Equal(134 + i, command.Parameters[4 * i + 2].Value);
Assert.Equal($"@embedding_{4 * i + 3}", command.Parameters[4 * i + 3].ParameterName);
var vector = Assert.IsType<SqlVector<float>>(command.Parameters[4 * i + 3].Value);
Assert.Equal([10 + i], vector.Memory.ToArray());
}
}
[Fact]
public void DeleteSingle()
{
KeyPropertyModel keyProperty = new("id", typeof(long));
using SqlConnection connection = CreateConnection();
using SqlCommand command = SqlServerCommandBuilder.DeleteSingle(connection,
"schema", "tableName", keyProperty, 123L);
Assert.Equal("DELETE FROM [schema].[tableName] WHERE [id] = @id_0", command.CommandText);
Assert.Equal(123L, command.Parameters[0].Value);
Assert.Equal("@id_0", command.Parameters[0].ParameterName);
}
[Fact]
public void DeleteMany()
{
string[] keys = ["key1", "key2"];
KeyPropertyModel keyProperty = new("id", typeof(string));
using SqlConnection connection = CreateConnection();
using SqlCommand command = connection.CreateCommand();
Assert.True(SqlServerCommandBuilder.DeleteMany(command, "schema", "tableName", keyProperty, keys));
Assert.Equal("DELETE FROM [schema].[tableName] WHERE [id] IN (@id_0,@id_1)", command.CommandText);
for (int i = 0; i < keys.Length; i++)
{
Assert.Equal(keys[i], command.Parameters[i].Value);
Assert.Equal($"@id_{i}", command.Parameters[i].ParameterName);
}
}
[Fact]
public void SelectSingle()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreDataProperty("age", typeof(int)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10)
]);
using SqlConnection connection = CreateConnection();
using SqlCommand command = SqlServerCommandBuilder.SelectSingle(connection, "schema", "tableName", model, 123L, includeVectors: true);
Assert.Equal(
"""""
SELECT [id],[name],[age],[embedding]
FROM [schema].[tableName]
WHERE [id] = @id_0
""""", command.CommandText, ignoreLineEndingDifferences: true);
Assert.Equal(123L, command.Parameters[0].Value);
Assert.Equal("@id_0", command.Parameters[0].ParameterName);
}
[Fact]
public void SelectMany()
{
var model = BuildModel(
[
new VectorStoreKeyProperty("id", typeof(long)),
new VectorStoreDataProperty("name", typeof(string)),
new VectorStoreDataProperty("age", typeof(int)),
new VectorStoreVectorProperty("embedding", typeof(ReadOnlyMemory<float>), 10)
]);
long[] keys = [123L, 456L, 789L];
using SqlConnection connection = CreateConnection();
using SqlCommand command = connection.CreateCommand();
Assert.True(SqlServerCommandBuilder.SelectMany(command,
"schema", "tableName", model, keys, includeVectors: true));
Assert.Equal(
"""""
SELECT [id],[name],[age],[embedding]
FROM [schema].[tableName]
WHERE [id] IN (@id_0,@id_1,@id_2)
""""", command.CommandText, ignoreLineEndingDifferences: true);
for (int i = 0; i < keys.Length; i++)
{
Assert.Equal(keys[i], command.Parameters[i].Value);
Assert.Equal($"@id_{i}", command.Parameters[i].ParameterName);
}
}
// We create a connection using a fake connection string just to be able to create the SqlCommand.
private static SqlConnection CreateConnection()
=> new("Server=localhost;Database=master;Integrated Security=True;");
private static CollectionModel BuildModel(List<VectorStoreProperty> properties)
=> new SqlServerModelBuilder()
.BuildDynamic(new() { Properties = properties }, defaultEmbeddingGenerator: null);
#if NET // NRT detection via NullabilityInfoContext is only available on .NET 6+
[Fact]
public void CreateTable_WithNrtAnnotations()
{
var model = new SqlServerModelBuilder().Build(
typeof(NrtTestRecord),
typeof(long),
definition: null,
defaultEmbeddingGenerator: null);
using SqlConnection connection = CreateConnection();
var commands = SqlServerCommandBuilder.CreateTable(connection, "schema", "table", ifNotExists: false, model);
var command = Assert.Single(commands);
Assert.Equal(
"""
BEGIN
CREATE TABLE [schema].[table] (
[Id] BIGINT IDENTITY,
[NonNullableString] NVARCHAR(MAX) NOT NULL,
[NullableString] NVARCHAR(MAX),
[NonNullableInt] INT NOT NULL,
[NullableInt] INT,
[NonNullableBool] BIT NOT NULL,
[Embedding] VECTOR(10) NOT NULL,
PRIMARY KEY ([Id])
);
END;
""", command.CommandText, ignoreLineEndingDifferences: true);
}
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor
#pragma warning disable CA1812 // Class is used via reflection
private sealed class NrtTestRecord
{
[VectorStoreKey]
public long Id { get; set; }
[VectorStoreData]
public string NonNullableString { get; set; }
[VectorStoreData]
public string? NullableString { get; set; }
[VectorStoreData]
public int NonNullableInt { get; set; }
[VectorStoreData]
public int? NullableInt { get; set; }
[VectorStoreData]
public bool NonNullableBool { get; set; }
[VectorStoreVector(10)]
public ReadOnlyMemory<float> Embedding { get; set; }
}
#pragma warning restore CA1812
#pragma warning restore CS8618
#endif
}