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

Ouverte
#3,634 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
28/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
csharp, postgresql
Domaine
backend, databases

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
C#
Étoiles
1.8k
Forks
268
Merge moyen
2 h 35 min
PR mergées (30 j)
136

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de npgsql/efcore.pg

Toutes les issues de npgsql/efcore.pg

Issues similaires

Plus d'issues C#

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.