-
Notifications
You must be signed in to change notification settings - Fork 1
Differences between DbFun and SqlFun
Jacek Hełka edited this page Dec 13, 2023
·
9 revisions
Both tools are based on the same idea of generating functions implementing database queries.
The most fundamental difference is, that since SqlFun requires a function signature as an input:
let getBlog = sql<int -> AsyncDb<Blog>> "select * from Blog where id = @id"DbFun allows to compose the function using various parameter and result specification objects:
let getBlog = queryBuilder.Sql("select * from Blog where id = @id", Params.Int "id", Results.Single<Blog>())with carefully chosen simplifications and defaults:
let getBlog = queryBuilder.Sql<int, Blog>("select * from Blog where id = @id", "id")Other differences are:
- DbFun creates only asynchronous query functions
- result transformations (
join,group,combine) are defined in the same layer as result processing functions - DbFun doesn't parse sql command to find parameter names, they must be specified directly with parameter definition objects or taken from compound objects (record or discrimintated union fields)
- parameters are never assigned positionally - simple type values or tuple fields must be explicitly named
- results are also never assigned positionally, they can be tuples or collections of tuples, but tuple fields must be named explicitly
- simple type or simple type collection results must be also explicitly named
- no convention-based result transformations - master records in join and group target fields are specified using quotations
- DbFun supports discriminated unions
- three types of enums are supported:
- int based
- char based
- discriminated unions without fields (serialized to strings)
- templated queries are integral part of a framework
- .NET 6 or higher is supported, no more .NET Framework support
- some framework elements has been named differently:
-
AsyncDbbecameDbCall -
asyncdbworkflow becamedbsession
-
- better compilation error reporting
In short:
- less magic
- more explicitness
- more composability
- more simplicity
- more features
