Skip to content

Commit 1b55ebc

Browse files
authored
Add NpgsqlTsVector.Empty (#6145)
Closes #6134
1 parent e3921f2 commit 1b55ebc

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/Npgsql/NpgsqlTypes/NpgsqlTsVector.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ namespace NpgsqlTypes;
1111
/// </summary>
1212
public sealed class NpgsqlTsVector : IEnumerable<NpgsqlTsVector.Lexeme>, IEquatable<NpgsqlTsVector>
1313
{
14+
/// <summary>
15+
/// Represents an empty tsvector.
16+
/// </summary>
17+
public static readonly NpgsqlTsVector Empty = new NpgsqlTsVector([], noCheck: true);
18+
1419
readonly List<Lexeme> _lexemes;
1520

1621
internal NpgsqlTsVector(List<Lexeme> lexemes, bool noCheck = false)

src/Npgsql/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ Npgsql.NpgsqlConnection.ReloadTypesAsync(System.Threading.CancellationToken canc
8484
*REMOVED*Npgsql.NpgsqlSlimDataSourceBuilder.MapComposite<T>(string? pgName = null, Npgsql.INpgsqlNameTranslator? nameTranslator = null) -> Npgsql.TypeMapping.INpgsqlTypeMapper!
8585
*REMOVED*Npgsql.NpgsqlSlimDataSourceBuilder.MapEnum(System.Type! clrType, string? pgName = null, Npgsql.INpgsqlNameTranslator? nameTranslator = null) -> Npgsql.TypeMapping.INpgsqlTypeMapper!
8686
*REMOVED*Npgsql.NpgsqlSlimDataSourceBuilder.MapEnum<TEnum>(string? pgName = null, Npgsql.INpgsqlNameTranslator? nameTranslator = null) -> Npgsql.TypeMapping.INpgsqlTypeMapper!
87+
static readonly NpgsqlTypes.NpgsqlTsVector.Empty -> NpgsqlTypes.NpgsqlTsVector!

test/Npgsql.Tests/TypesTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ public void TsQuery()
8686
}
8787
#pragma warning restore CS0618 // {NpgsqlTsVector,NpgsqlTsQuery}.Parse are obsolete
8888

89+
[Test]
90+
public void TsVector_empty()
91+
{
92+
Assert.IsEmpty(NpgsqlTsVector.Empty);
93+
Assert.AreEqual(string.Empty, NpgsqlTsVector.Empty.ToString());
94+
}
95+
8996
[Test]
9097
public void TsQueryEquatibility()
9198
{

0 commit comments

Comments
 (0)