-
Notifications
You must be signed in to change notification settings - Fork 175
Rework VALUES clause and fix a bug on SQLite #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,11 +112,17 @@ values_ :: forall be db s a | |
, BeamSqlBackend be ) | ||
=> [ a ] -> Q be db s a | ||
values_ rows = | ||
Q $ liftF (QAll (\tblPfx -> fromTable (tableFromValues (map (\row -> project (Proxy @be) row tblPfx) rows)) . Just . (,Just fieldNames)) | ||
(\tblNm' -> fst $ mkFieldNames (qualifiedField tblNm')) | ||
Q $ liftF (QAll (\tblPfx -> fromTable (tableFromValues colCount (map (\row -> project (Proxy @be) row tblPfx) rows)) . Just . (,colAliases)) | ||
(\tblNm' -> if useAliases | ||
then fst $ mkFieldNames (qualifiedField tblNm') | ||
else fst $ mkDefaultFieldNames (qualifiedField tblNm')) | ||
(\_ -> Nothing) snd) | ||
where | ||
useAliases = knownBool @(BeamSqlBackendSupportsColumnAliases be) | ||
colAliases | useAliases = Just fieldNames | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to use type-level bools for this? Seems like a typeclass method using either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point.. yeah that would be easier |
||
| otherwise = Nothing | ||
fieldNames = snd $ mkFieldNames @be @a unqualifiedField | ||
colCount = length fieldNames | ||
|
||
-- | Introduce all entries of a table into the 'Q' monad based on the | ||
-- given QExpr. The join condition is expected to return a | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to see a little comment here about what this
Int
representsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the number of columns in the result (in the case that the expressions list is empty, we wouldn't be able to infer that from the values).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant as documentation, just like you did in
tableFromValues