Skip to content

Commit

Permalink
handle encoding the SELECT_DISTINCT query type
Browse files Browse the repository at this point in the history
  • Loading branch information
emdash committed Dec 4, 2023
1 parent 1139c97 commit b5e3240
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Sqlite3/Parameter.idr
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,14 @@ encodeHaving x = do
||| inserted as placeholders for literal values where appropriate.
export
encodeQuery : Query ts -> ParamStmt
encodeQuery (Q _ from vs where_ having group_by order_by lim off) = do
encodeQuery (Q distinct _ from vs where_ having group_by order_by lim off) = do
vstr <- namedExprs [<] vs
fstr <- encodeFrom from
wh <- encodeExprP where_
hav <- encodeHaving having
grp <- encodeOrd "GROUP BY" (map ord group_by)
ord <- encodeOrd "ORDER BY" order_by
pure "SELECT \{vstr} \{fstr} WHERE \{wh} \{grp} \{hav} \{ord} \{limit lim off}"
let rest = "\{vstr} \{fstr} WHERE \{wh} \{grp} \{hav} \{ord} \{limit lim off}"
pure $ case distinct of
True => "SELECT DISTINCT \{rest}"
False => "SELECT \{rest}"

0 comments on commit b5e3240

Please sign in to comment.