Storing Auto-generated TS Vector from Unmapped Fields

オープン
#3,352 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp, postgresql
領域
databases

調査の方向性

Start with the HasGeneratedTsVectorColumn configuration shown in the issue and trace the failure through NpgsqlAnnotationProvider.For and the EF Core column-name lookup in the stack trace. Reproduce the model with the [NotMapped] source property and inspect the provider’s existing generated-tsvector tests. Done means the model can be created with the unmapped source property and the generated tsvector column works without storing the raw text.

索引モデルが issue の本文から書いたものです。

説明

I would like to store only a tsvector column in my PostgreSQL table without saving the original text itself. To achieve this, I have created a text variable in my model class and marked it with [NotMapped].

The model is configured so that the tsvector column is automatically generated based on the content of this unmapped text property. It would be very helpful if EF Core could support storing auto-generated tsvector columns derived from unmapped fields, allowing us to keep the tsvector for full-text search while avoiding storage of the raw text.

Model:

    [NotMapped]
    public required string FullTextSearch { get; set; }
    public NpgsqlTsVector FullSearchVector { get; set; } 

Model Configuration:

builder.HasGeneratedTsVectorColumn(record => record.FullSearchVector, 
       "english",
        record => record.FullTextSearch);

Exception:

 System.NullReferenceException: Object reference not set to an instance of an object.
         at Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalPropertyOverrides.Find(IReadOnlyProperty property, StoreObjectIdentifier& storeObject)
         at Microsoft.EntityFrameworkCore.RelationalPropertyExtensions.FindOverrides(IReadOnlyProperty property, StoreObjectIdentifier& storeObject)
         at Microsoft.EntityFrameworkCore.RelationalPropertyExtensions.GetColumnName(IReadOnlyProperty property, StoreObjectIdentifier& storeObject)
         at Npgsql.EntityFrameworkCore.PostgreSQL.Metadata.Internal.NpgsqlAnnotationProvider.<>c__DisplayClass2_1.<For>b__10(String p2)
         at System.Linq.Enumerable.SelectArrayIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
         at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
         at Npgsql.EntityFrameworkCore.PostgreSQL.Metadata.Internal.NpgsqlAnnotationProvider.For(IColumn column, Boolean designTime)+MoveNext()
         at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase.AddAnnotations(AnnotatableBase annotatable, IEnumerable`1 annotations)
         at Microsoft.EntityFrameworkCore.Infrastructure.AnnotatableBase.AddAnnotations(IEnumerable`1 annotations)
         at Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalModel.Create(IModel model, IRelationalAnnotationProvider relationalAnnotationProvider, IRelationalTypeMappingSource relationalTypeMappingSource, Boolean designTime)
         at Microsoft.EntityFrameworkCore.Metadata.Internal.RelationalModel.Add(IModel model, IRelationalAnnotationProvider relationalAnnotationProvider, IRelationalTypeMappingSource relationalTypeMappingSource, Boolean designTime)
         at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelRuntimeInitializer.InitializeModel(IModel model, Boolean designTime, Boolean prevalidation)
         at Microsoft.EntityFrameworkCore.Infrastructure.ModelRuntimeInitializer.Initialize(IModel model, Boolean designTime, IDiagnosticsLogger`1 validationLogger)
         at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, ModelCreationDependencies modelCreationDependencies, Boolean designTime)
         at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Boolean designTime)
         at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_DesignTimeModel()
         at Microsoft.EntityFrameworkCore.Metadata.Internal.DesignTimeModel.get_Model()
         at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.CreateTablesAsync(CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreatedAsync(CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Storage.RelationalDatabaseCreator.EnsureCreatedAsync(CancellationToken cancellationToken)
主要言語
C#
スター
1.8k
フォーク
268
平均マージ
2時間 35分
マージ済み PR(30日)
136

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

npgsql/efcore.pg のほかの issue

npgsql/efcore.pg の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。