Problematic writing generic queries with open rows #36
Labels
add to guide
Use case worth including in the guide
backend-integration
Interop code between DSL and some db backend, e.g. generate SQL, execute, [de]serialize results
error message
Refers to compilation errors (unclear, misleading, ...)
query-level
Change related to query DSL. Includes changes to `Query` datatype and its internals.
Writing such queries often requires providing type signatures including type class constraints.
The query below uses a combination of
selectFrom
andquery1
that require complicated constraints. The table row is open thus these constraints need to persist - it is advised to write the 'top-level constraints' (FromTable
inselectFrom
andGenericQuery
inquery1
) attached to those functions (in their signatures) and don't let the compiler unfold them.To type-check the function below we need to provide the type signature ourself - or satisfy ourselves with concrete and closed table-row
t
and let the compiler solve these constraints immediately.Please note that the query (returned by
selectFrom
) is defined separately in thewhere
clause.Somehow with the proper type signature, the function
getUserByEmail
does not type-check if we inline the queryq
.This should be mentioned in the guide.
The text was updated successfully, but these errors were encountered: