Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/EFCore.PG/Storage/Internal/NpgsqlTypeMappingSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@ public NpgsqlTypeMappingSource(
{ typeof(NpgsqlRange<DateTimeOffset>), _tstzrange },
{ typeof(NpgsqlRange<DateOnly>), _dateOnlyDaterange },
{ typeof(NpgsqlTsQuery), _tsquery },
{ typeof(NpgsqlTsQueryLexeme), _tsquery },
{ typeof(NpgsqlTsQueryNot), _tsquery },
{ typeof(NpgsqlTsQueryBinOp), _tsquery },
{ typeof(NpgsqlTsQueryAnd), _tsquery },
{ typeof(NpgsqlTsQueryOr), _tsquery },
{ typeof(NpgsqlTsQueryFollowedBy), _tsquery },
{ typeof(NpgsqlTsQueryEmpty), _tsquery },
{ typeof(NpgsqlTsVector), _tsvector },
{ typeof(NpgsqlTsRankingNormalization), _rankingNormalization },
{ typeof(LTree), _ltree }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,29 @@ LIMIT 1
""");
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task Matches_with_derived_tsquery_parameter(bool async)
{
using var context = CreateContext();
var tsQuery = new NpgsqlTsQueryLexeme("firs", NpgsqlTsQueryLexeme.Weight.None, true);
var query = context.Customers
.Select(c => EF.Functions.ToTsVector("simple", "first").Matches(tsQuery));

var results = async ? await query.ToArrayAsync() : query.ToArray();

Assert.NotEmpty(results);
Assert.All(results, Assert.True);
AssertSql(
"""
@__tsQuery_1=''firs':*' (DbType = Object)

SELECT to_tsvector('simple', 'first') @@ @__tsQuery_1
FROM "Customers" AS c
""");
}

[Fact]
public void TsVector_Concat()
{
Expand Down
16 changes: 16 additions & 0 deletions test/EFCore.PG.Tests/Storage/NpgsqlTypeMappingSourceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ public void By_ClrType(Type clrType, string expectedStoreType)
Assert.Same(clrType, mapping.ClrType);
}

[Theory]
[InlineData(typeof(NpgsqlTsQuery))]
[InlineData(typeof(NpgsqlTsQueryLexeme))]
[InlineData(typeof(NpgsqlTsQueryNot))]
[InlineData(typeof(NpgsqlTsQueryBinOp))]
[InlineData(typeof(NpgsqlTsQueryAnd))]
[InlineData(typeof(NpgsqlTsQueryOr))]
[InlineData(typeof(NpgsqlTsQueryFollowedBy))]
[InlineData(typeof(NpgsqlTsQueryEmpty))]
public void TsQuery(Type clrType)
{
var mapping = Assert.IsType<NpgsqlTsQueryTypeMapping>(CreateTypeMappingSource().FindMapping(clrType));
Assert.Equal("tsquery", mapping.StoreType);
Assert.Same(typeof(NpgsqlTsQuery), mapping.ClrType);
}

[Theory]
[InlineData(typeof(decimal), "numeric(5)")]
[InlineData(typeof(DateTime), "timestamp(5) with time zone")]
Expand Down
Loading