Typesafe dynamic filtering/ordering/paging
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
The issue names no repository files or tests. Start by locating the SQL<...> generated-type path described here and trace how output columns are exposed. Done means eligible single-SELECT queries support type-safe By values, ordering, paging, and a command that preserves the applied clauses.
Written by the indexing model from the issue text.
Description
Right now there is no way to dynamically order queries.
This makes the library unsuitable for applications that let the user sort a paged table of records.
That's a lot of applications!
This should be solvable without giving up type safety. Here's the design I have in mind:
Any command that consists of a single SELECT statement which is not known to be a single-row SELECT should be dynamically orderable.
e.g.
type MyQuery = SQL<"select Column1, 1+1 as Column2 from SomeTable">
This means that it gets the following extra stuff in its generated type:
- A nested type
MyQuery.Bywith a private constructor and an overrided ToString(). - Static getters
MyQuery.By.Column1andMyQuery.By.Column2, which return instances ofMyQuery.By - A static method
MyQuery.By.OfString("Column1")which checks that the passed string is one of the statically known output column names.MyQuery.By.OfString(MyQuery.By.Column2.ToString())should work. - A static
OrderBymethod taking aMyQuery.Byand a DUAscending|Descendingand returning aMyQuery.OrderedQuery MyQuery.OrderedQueryhas an instance methodThenBytaking another by+direction,Pagetaking limit+offsetMyQuery.OrderedQueryhas an instanceCommandmethod which is like the regularMyQuery.Command(param1 = ...)method, but includes the orderings applied so far
Hypothetical usage:
type MyQuery = SQL<"select Column1, 1+1 as Column2 from SomeTable where Name like @name">
let example (conn : ConnectionContext) =
MyQuery
.OrderBy(MyQuery.By.Column1, Ascending)
.ThenBy(MyQuery.By.Column2, Descending)
.Page(25, 50)
.Command(name = "%a%")
.Execute(conn)
I think it would be OK to limit to one ThenBy clause. Orderings more complicated than that don't make much sense to generate dynamically.
Thoughts?
- Dominant language
- F#
- Stars
- 680
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
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/Rezoom.SQL
-
Difficulty 2/5 1-3 hours Newbie friendliness 20/100
fsprojects/Rezoom.SQL#57 · 1 comment ·
-
Dacpac support info Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
fsprojects/Rezoom.SQL#56 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
fsprojects/Rezoom.SQL#52 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
fsprojects/Rezoom.SQL#50 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
fsprojects/Rezoom.SQL#48 · 3 comments ·
All issues in fsprojects/Rezoom.SQL
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
EricSpencer00/Resilient#4824 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/jeo-maven-plugin#1758 ·
-
mlir
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
llvm/llvm-project#224908 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100