Translate Array[][].Contains(x.<array property>)

Aperta
#3,634 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
28/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
csharp, postgresql
Ambito
backend, databases

Direzione di ricerca

This is a query-translation gap in the Npgsql EF Core provider for nested int[] compared with SequenceEqual, Contains, or Join. Reproduce with the Part entity and the three snippets in the issue against Npgsql.EntityFrameworkCore.PostgreSQL 9.0.4; the errors mention unnest(... ) WITH ORDINALITY lacking a type mapping. Start from how array and nested-array type mappings are applied in the SQL tree, then add coverage for Contains/SequenceEqual/Join of array-of-array parameters. Done when those LINQ shapes translate and execute without the mapping exceptions.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I encountered another issue regarding arrays.

I have a class with an array property:

public class Part {
    public int Id { get; set; }
    public int[] TaxonomyPath { get; set; }
}

Now I want to query for all Parts where TaxonomyPath is in [[1, 2], [4,7], [3,9]]:

int[][] expected = [[1, 2], [4,7], [3,9]];
await dbContext.Parts
    .Where(x => expected.Any(e => x.TaxonomyPath.SequenceEqual(e)))
    .ToArrayAsync();

This throws:

Expression 'unnest(@__existing_0) WITH ORDINALITY AS e(value)' in the SQL tree does not have a type mapping assigned.

When I change SequenceEqual to == it throws:

Couldn't find array type mapping when applying item/array mappings

Same when using Where(x => expected.Contains(x.TaxonomyPath).

Also when joining (which is the actual goal):

int[][] expected = [[1, 2], [4,7], [3,9]];
await dbContext.Parts
            .Join(expected,
                x => x.TaxonomyPath,
                x => x,
                (p, _) => p)
    .ToArrayAsync();

It throws:

Expression 'unnest(@__p_0) WITH ORDINALITY AS p(value)' in the SQL tree does not have a type mapping assigned.

I am using Npgsql.EntityFrameworkCore.PostgreSQL 9.0.4.

Lingua principale
C#
Stelle
1.8k
Fork
268
Merge medio
2h 35m
PR unite (30g)
136

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npgsql/efcore.pg

Tutte le issue di npgsql/efcore.pg

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.