-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An enum property isn't mapped to the PostgreSQL enum inside value objects #623
Comments
@YohDeadfall Do you mind if I wrap this into #605 which attempts to address some other enum edge cases? |
I think that such changes should be made by separate pull requests. One issue - one request. But let's leave it as is this time. |
@YohDeadfall When I read this earlier, I thought there might be some overlap, but I was indeed mistaken. Once #605 is merged, I'll take a look at this one separately. |
I'm going to add this to 2.2.0 for now, hoping we can fix it by the time we release. |
FYI starting to look into this now. Notes
|
Actually, I can't reproduce this in the test suite. The 2.2 release notes do reference changes to owned type behavior, so it's possible that this was simply resolved upstream. @YohDeadfall Here's the setup I used to try and reproduce this. Does the configuration look right? Are you still able to reproduce this locally? [Fact]
public void Where_with_owned_type()
{
using (var ctx = Fixture.CreateContext())
{
var _ = ctx.SomeEntities.Single(e => e.OwnedTypeWithEnum.MappedEnum == MappedEnum.Happy);
AssertContainsInSql("WHERE e.\"OwnedTypeWithEnum_MappedEnum\" = 'happy'::test.mapped_enum");
}
} public class SomeEnumEntity
{
public int Id { get; set; }
public MappedEnum MappedEnum { get; set; }
public UnmappedEnum UnmappedEnum { get; set; }
public InferredEnum InferredEnum { get; set; }
public SchemaQualifiedEnum SchemaQualifiedEnum { get; set; }
public int EnumValue { get; set; }
public OwnedTypeWithEnum OwnedTypeWithEnum { get; set; }
}
public class OwnedTypeWithEnum
{
public MappedEnum MappedEnum { get; set; }
public UnmappedEnum UnmappedEnum { get; set; }
public InferredEnum InferredEnum { get; set; }
public SchemaQualifiedEnum SchemaQualifiedEnum { get; set; }
public int EnumValue { get; set; }
} protected override void OnModelCreating(ModelBuilder builder)
{
builder.ForNpgsqlHasEnum("mapped_enum", new[] { "happy", "sad" })
.ForNpgsqlHasEnum<InferredEnum>()
.HasDefaultSchema("test")
.ForNpgsqlHasEnum<SchemaQualifiedEnum>();
builder.Entity<SomeEnumEntity>().OwnsOne(x => x.OwnedTypeWithEnum);
} Note that I tested this in a branch following #685, so the schema handling may look different from the current |
We have moved out from EF for the current project (: Will check it when I have half an hour to spare. |
@YohDeadfall hope it's nothing bad with EF :) Do you want to continue being active and reviewing EF stuff or only Npgsql? |
It's very limited for our goals and too slow in comparison with pure Npgsql and SQL, but we will continue to use it for migrations only which are written in plain SQL (: Yes, I want to work on EF too, but currently I'm busy with the presentation I mentioned in person. It covers npgsql/npgsql#2180. |
OK, great - we can also use your work to write that page on migrating from MSSQL. Good luck with the presentation! |
Looks like I've omitted some part that triggers the problem or most likely had an issue in the application... Closing as I can't reproduce it too. Thanks for taking a look! |
The problem occurs only for value objects inside complex objects. The following example maps
PhoneNumberType
toint
:The text was updated successfully, but these errors were encountered: