Translate primitive collections with composed LINQ operators via PG array constructor

オープン
#3,208 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@roji がすでに取り組んでいます。

2024年6月23日 から。

評価

この issue はまだ評価されていません。

説明

When a primitive collection has a LINQ operator composed on top of it, we convert it to a rowset via unnest, insert it via a lateral join into the query, and then process the query as usual:

_ = await context.Blogs
    .Select(b => b.Ints.Select(i => i + 1).ToArray())
    .ToListAsync();

Current SQL:

SELECT b."Id", i.value + 1, i.ordinality
FROM "Blogs" AS b
LEFT JOIN LATERAL unnest(b."Ints") WITH ORDINALITY AS i(value) ON TRUE
ORDER BY b."Id" -- currently missing ordinality, #3207

Instead, we could simply use the array constructor operator to convert the subquery directly into an array:

SELECT ARRAY(SELECT i + 1 FROM unnest(b."Ints"))
FROM "Blogs" AS b

The tricky part here is to figure out exactly when to wrap the subquery in ARRAY(), as opposed to when to leave the classical relational translation with lateral join.

主要言語
C#
スター
1.8k
フォーク
268
平均マージ
2時間 35分
マージ済み PR(30日)
136

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

npgsql/efcore.pg のほかの issue

npgsql/efcore.pg の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。