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/Parser.hs | |
parent | 58e1cf274e80d8dbd4889bb2c99d3a009b590282 (diff) |
add `LIMIT`, `ORDER BY` clausesmain
Diffstat (limited to 'src/Store/Query/Parser.hs')
-rw-r--r-- | src/Store/Query/Parser.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Store/Query/Parser.hs b/src/Store/Query/Parser.hs index 99ddc79..5b7bc1b 100644 --- a/src/Store/Query/Parser.hs +++ b/src/Store/Query/Parser.hs @@ -51,7 +51,11 @@ instance IsString Query where w <- P.optional do where_ whereClause - pure $ Select fs c js es w, + l <- P.optional do + limitClause + o <- P.optional do + offsetClause + pure $ Select fs c js es w l o, do update c <- collection @@ -83,6 +87,8 @@ instance IsString Query where or = void $ lexeme (P.string "OR") select = void $ lexeme (P.string "SELECT") where_ = void $ lexeme (P.string "WHERE") + offset_ = void $ lexeme (P.string "OFFSET") + limit_ = void $ lexeme (P.string "LIMIT") collection = lexeme $ P.takeWhile1P (Just "collection") (not . isSpace) @@ -119,6 +125,14 @@ instance IsString Query where b <- P.choice [Left <$> value, Right <$> field] pure $ Eq a b + offsetClause = do + offset_ + Offset <$> lexeme P.decimal + + limitClause = do + limit_ + Limit <$> lexeme P.decimal + fieldSelector = lexeme $ P.choice |