Typesafe dynamic filtering/ordering/paging
还没有人认领这个 Issue。
评估
调研方向
该 issue 未指明 repository 文件或测试。首先定位此处描述的 SQL... 生成类型路径,并跟踪输出列的暴露方式。完成标准是:符合条件的单 SELECT 查询支持类型安全的 By 值、排序、分页,以及一个保留所应用子句的命令。
由索引模型根据 Issue 内容生成。
描述
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?
- 主要语言
- F#
- 星标
- 680
- 派生
- 23
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fsprojects/Rezoom.SQL 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 20/100
fsprojects/Rezoom.SQL#57 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 20/100
fsprojects/Rezoom.SQL#56 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
fsprojects/Rezoom.SQL#52 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 20/100
fsprojects/Rezoom.SQL#50 ·
-
难度 5/5 一周以上 新手友好度 25/100
fsprojects/Rezoom.SQL#48 · 3 条评论 ·
查看 fsprojects/Rezoom.SQL 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
jaseci-labs/jac#9934 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
rescript-lang/rescript#8763 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 62/100
flagos-ai/FlagTree#1344 · 1 条评论 ·
维护者通常 1 天内回复