Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

SqlExp and SqlQuery

オープン
#391 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
fsharp, sql
領域
databases

調査の方向性

まず、issue にある SqlExp と SqlQuery の定義、および SQL クエリを F# データ構造にパースする既存の取り組みを確認します。それらのモデルのいずれかで並べ替えの例を表現し、SQL も生成できるかを判断します。選択したモデルが、文書化された実行時の不一致なしに、これらの複雑なクエリ形状を処理できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

enhancement question

We are currently modelling our SQL-expressions with quite simple context:

SqlExp =
    | BaseTable    of alias * Table                      // name of the initiating IQueryable table - this isn't always the ultimate table that is selected
    | SelectMany   of alias * alias * SelectData * SqlExp  // from alias, to alias and join data including to and from table names. Note both the select many and join syntax end up here
    | FilterClause of Condition * SqlExp                 // filters from the where clause(es)
    | HavingClause of Condition * SqlExp                 // filters from the where clause(es)
    | Projection   of Expression * SqlExp                // entire LINQ projection expression tree
    | Distinct     of SqlExp                             // distinct indicator
    | OrderBy      of alias * string * bool * SqlExp     // alias and column name, bool indicates ascending sort
    | Union        of bool * string * SqlExp             // true = "union all", false = "union", and subquery
    | Skip         of int * SqlExp
    | Take         of int * SqlExp
    | Count        of SqlExp
    | AggregateOp  of AggregateOperation * alias * string * SqlExp

and SqlQuery =
    { Filters       : Condition list
      HavingFilters : Condition list
      Links         : (alias * LinkData * alias) list
      Aliases       : Map<string, Table>
      Ordering      : (alias * string * bool) list
      Projection    : Expression list
      Grouping      : (list<alias * string> * list<AggregateOperation * alias * string>) list //key columns, aggregate columns
      Distinct      : bool
      UltimateChild : (string * Table) option
      Skip          : int option
      Take          : int option
      Union         : (bool*string) option
      Count         : bool 
      AggregateOp   : (AggregateOperation * alias * string) list }

The problem is that we will fail more complex SQL:s, e.g. if you have multiple items like Skips:

select x from xs
skip 1
skip 1
take 1

That code should take 3 from [1;2;3;4] but actually would take 2, but we know this and fail runtime. But then again, the SQL can be more weird, where we can't fail but we expect the typical execution order while the real results should be something else:

select x from xs
take 5
where x > 3
join y in ys

We use our model to generate model -> SQL. There are multiple efforts to do the other way, parse SQL-queries to F# data structures SQL -> model.

Could we, instead of having our own model, steal some model from those efforts, and reverse the functionality to generate SQL?

主要言語
F#
スター
627
フォーク
147
平均マージ
2時間 2分
マージ済み PR(30日)
1

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

fsprojects/SQLProvider のほかの issue

fsprojects/SQLProvider の issue をすべて見る

似ている issue

Databases の issue をもっと見る

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

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