Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

SqlExp and SqlQuery

Đang mở
#391 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
fsharp, sql
Lĩnh vực
databases

Hướng nghiên cứu

Bắt đầu bằng cách xem xét các định nghĩa SqlExp và SqlQuery trong issue cùng những nỗ lực hiện có để phân tích các truy vấn SQL thành các cấu trúc dữ liệu F#. Xác định xem một trong các mô hình đó có thể biểu diễn các ví dụ về sắp xếp mà vẫn tạo được SQL hay không; được xem là hoàn thành khi mô hình được chọn xử lý được các dạng truy vấn phức tạp này mà không gặp lỗi không tương thích trong thời gian chạy đã được ghi nhận.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
F#
Star
627
Fork
147
Merge trung bình
2 giờ 2 phút
Pull request đã merge (30 ngày)
1

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fsprojects/SQLProvider

Tất cả issue của fsprojects/SQLProvider

Issue tương tự

Thêm issue về Databases

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.