diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-12-18 19:11:57 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-12-18 19:12:01 +0100 |
commit | 593a53511ec170c67fd3453c88dcda960eac44fe (patch) | |
tree | ba9ce2d062649809959a4e21708db6e86fae6b97 /src/Store/Query/Printer.hs | |
parent | 58e1cf274e80d8dbd4889bb2c99d3a009b590282 (diff) |
add `LIMIT`, `ORDER BY` clausesmain
Diffstat (limited to 'src/Store/Query/Printer.hs')
-rw-r--r-- | src/Store/Query/Printer.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Store/Query/Printer.hs b/src/Store/Query/Printer.hs index cff543f..ecde378 100644 --- a/src/Store/Query/Printer.hs +++ b/src/Store/Query/Printer.hs @@ -26,7 +26,7 @@ instance Show Query where Just "INTO", Just (showCollection c) ] - show (Select fs c js es w) = + show (Select fs c js es w l o) = intercalate " " . catMaybes $ [ Just "SELECT", Just (showFieldSelector fs), @@ -34,7 +34,9 @@ instance Show Query where Just (showCollection c), showJoinClauses js, showEmbedClauses es, - showWhereClause w + showWhereClause w, + showLimitClause l, + showOffsetClause o ] show (Update c v w) = intercalate " " . catMaybes $ @@ -106,6 +108,14 @@ showComparison (Eq a b) = intercalate " " [showArg a, "==", showArg b] where showArg = either showValue showField +showOffsetClause :: Maybe OffsetClause -> Maybe String +showOffsetClause (Just (Offset n)) = Just (" OFFSET %d" <> show n) +showOffsetClause Nothing = Nothing + +showLimitClause :: Maybe LimitClause -> Maybe String +showLimitClause (Just (Limit n)) = Just (" LIMIT %d" <> show n) +showLimitClause Nothing = Nothing + showValues :: [J.Value] -> Maybe String showValues [] = Nothing showValues vs = Just (intercalate ", " (map showValue vs)) |