Failed to save string value to PostgreSQL enum column
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Start by checking how EF Core value conversions interact with Npgsql's PostgreSQL enum mapping; the report provides a converter, model configuration, SQL schema, and exception, but names no repository files or tests. Reproduce the save failure with the provided setup, then look for relevant provider tests or documentation. Done means establishing whether this configuration can save the value and documenting or fixing the behavior.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
I have C# value object together with convert like this:
public record DomainType
{
public string Value { get; }
public static readonly DomainType DomainTypeValue1 = new("DomainTypeValue1");
public static readonly DomainType DomainTypeValue2 = new("DomainTypeValue2");
public static readonly DomainType DomainTypeValue3 = new("DomainTypeValue3");
private DomainType(string value)
{
Value = value;
}
public static DomainType From(string value)
{
return new DomainType(value);
}
public override string ToString()
{
return Value;
}
}
public class DomainTypeConverter() : ValueConverter<DomainType, string>(v => v.Value, v => DomainType.From(v));
I use this type in the entity:
[EntityTypeConfiguration<DomainEntityModelBuilder, DomainEntity>]
[Table("domain_entity", Schema = "my_schema")]
public class DomainEntity
{
public required Guid Id { get; init; }
public required DomainType EntityType { get; init; }
}
Model builder looks like this:
public class DomainEntityModelBuilder : IEntityTypeConfiguration<DomainEntity>
{
public void Configure(EntityTypeBuilder<DomainEntity> entity)
{
entity.Property(d => d.Id).ValueGeneratedNever();
entity
.Property(d => d.EntityType )
.HasColumnName("entity_type")
.HasConversion<DomainTypeConverter>()
.HasColumnType("my_schema.domain_type");
}
}
Sql to create enum and type looks like this:
CREATE TYPE my_schema.domain_type AS ENUM ('DomainTypeValue1', 'DomainTypeValue2', 'DomainTypeValue3');
CREATE TABLE my_schema.domain_entity
(
id UUID PRIMARY KEY NOT NULL,
entity_type my_schema.domain_type NOT NULL
)
When I tried to save DomainEntity I get error:
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
---> Npgsql.PostgresException (0x80004005): 42804: column "entity_type" is of type my_schema.domain_type but expression is of type text
Is it possible to save text value as a postgres enum type?
- Linguagem predominante
- C#
- Estrelas
- 1.8k
- Forks
- 268
- Merge médio
- 2h 35min
- PRs com merge (30d)
- 136
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de npgsql/efcore.pg
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
NTS: the M ordinate is dropped from geometry SQL literals and from geometries stored in JSONTalvez já em andamento @Ahmed7991 assumiu há 6 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
npgsql/efcore.pg#4093 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
`TimeSpan`/`Duration` component members: negative values are floored, and intervals computed in SQL are read field by fieldTalvez já em andamento @jeremy-morren assumiu há 12 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
Numeric storage parameters are formatted with the current culture, so migrations emit 0,01 instead of 0.01Talvez já em andamento @Sorbitol assumiu há 12 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 30/100
Mantenedores costumam responder em até 1 dia
-
`Contains` on a JSON primitive collection compares JSON text, so `DateTime` and `TimeOnly` items never matchTalvez já em andamento @Mr444-dev assumiu há 8 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
npgsql/efcore.pg#4099 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de npgsql/efcore.pg
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
SubtitleEdit/subtitleedit#16825 ·
Mantenedores costumam responder em até 1 dia
-
ci-flake kind:tests size:S type:bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
elsa-workflows/elsa-foundation#4058 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
games-on-whales/wolf-ui#23 ·
-
SkillsAbertawayfinder:grilling
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
DigiBanks99/lopen#37 ·
-
:watch: Not Triaged aspnet-core/svc razor-pages/subsvc Source - Docs.ms
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
dotnet/AspNetCore.Docs#38126 ·
Mantenedores costumam responder em até 1 dia