-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
JSON column translation fails when using .Union() #33378
Comments
Confirmed, see minimal repro below. @maumar does this look familiar? I haven't seen an issue already tracking this (putting on your list for now - but not necessarily for fixing right away). Minimal reproawait using var context = new BlogContext();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
_ = context.Things
.Where(t => t.Id % 2 == 0)
.Union(context.Things.Where(t => t.Id % 3 == 0))
.ToList();
// .Count(); // Works
public class BlogContext : DbContext
{
public DbSet<Thing> Things { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer("Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Thing>().OwnsOne(
t => t.Metadata, ownedNavigationBuilder =>
{
ownedNavigationBuilder.ToJson();
});
}
}
public class Thing
{
public int Id { get; set; }
public ThingMetadata Metadata { get; set; }
}
[Owned]
public class ThingMetadata
{
public string SomeProperty { get; set; }
} |
Workaround: query for both sources to union separately and union them on the client. |
Problem is SelectExpression.ApplyUnion. When we get there, we have 2 queries as input, whose projection mapping is EmptyProjectionMember to ClassA, which inside stores owned navigation map entry to ClassB (via Test navigation). |
note that this is probably broken for other scenarios as well, basically anything with pushdown (?) - see #32911 for potential scenarios to test when fixing this |
In my case, I can't do this because I have many duplicates, I have several performance-critical areas that use set operations and it's |
@maumar not a regression, right? |
not a regression, exactly same error happens on 7 |
(Moved from npgsql/efcore.pg#3042)
I'm using Npgsql.EntityFrameworkCore.PostgreSQL 8.0.0 and one table has a JSON column.
Queries on this table fail if they return entities and use .Union():
Minimal repro against sqlite by @WhatzGames:
The text was updated successfully, but these errors were encountered: