SqlExp and SqlQuery
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reviewing the SqlExp and SqlQuery definitions in the issue and the existing efforts to parse SQL queries into F# data structures. Determine whether one of those models can represent the ordering examples and still generate SQL; done means the chosen model handles these complex query shapes without the documented runtime mismatch.
Written by the indexing model from the issue text.
Description
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?
- Dominant language
- F#
- Stars
- 627
- Forks
- 147
- Avg merge
- 2h 2m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fsprojects/SQLProvider
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 55/100
fsprojects/SQLProvider#872 · 2 comments ·
-
Repo Assist? Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 10/100
fsprojects/SQLProvider#870 · 1 comment ·
-
postgresql
Difficulty 4/5 3-5 days Newbie friendliness 58/100
fsprojects/SQLProvider#869 · 2 comments ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
fsprojects/SQLProvider#868 · 2 comments ·
-
sql server
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fsprojects/SQLProvider#851 · 1 comment ·
All issues in fsprojects/SQLProvider
Similar issues
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
community-scripts/ProxmoxVE#17396 · 1 comment ·
-
bug possible-duplicate
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
AOSSIE-Org/PictoPy#1553 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BasedHardware/omi#15274 · 3 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100