aboutsummaryrefslogtreecommitdiffstats
path: root/app/Main.hs
blob: 5574afa60c924250841ee2b4009674f0617dab97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module Main
  ( main,
  )
where

import Data.Aeson qualified as J
import Data.ByteString.Lazy.Char8 qualified as LB
import Store qualified as Q
import System.Directory (setCurrentDirectory)
import Text.Printf (printf)

main :: IO ()
main = do
  setCurrentDirectory "./data"

  mapM_
    ( \q -> do
        printf "> %s\n" (show q)
        query' q
    )
    [ "SELECT * FROM c",
      "SELECT * FROM j",
      "SELECT c.id, j.id, is_j FROM c LEFT JOIN j ON j.id == c.j_id",
      "SELECT c.id, j.id FROM c RIGHT JOIN j ON j.id == c.j_id",
      "SELECT c.id, j.id FROM c FULL JOIN j ON j.id == c.j_id",
      "SELECT c.id, j FROM c EMBED j ON j.id == c.j_id"
    ]

query' :: Q.Query -> IO ()
query' q = mapM_ (LB.putStrLn . J.encode) =<< Q.query q