From 1a8e94e85977bd4d3781082b37186f6319309631 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 15 Feb 2015 13:54:04 -0400 Subject: update, fixing compilation and fixing to actually do a join --- fooes.hs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'fooes.hs') diff --git a/fooes.hs b/fooes.hs index 80f4b7dc5..cdc95bdff 100644 --- a/fooes.hs +++ b/fooes.hs @@ -22,15 +22,21 @@ AssociatedFiles main :: IO () main = runSqlite "foo.db" $ do runMigration migrateAll + if True then populate else return () + query +populate = do forM_ [1..30000] $ \i -> do + --delete $ from $ \f -> do + -- where_ (f ^. CachedKeyKey ==. val (show i)) k <- insert $ CachedKey (show i) - liftIO $ print k - insert $ AssociatedFiles k (show i) + liftIO $ print ("stored", k) + insert $ AssociatedFiles k ("file" ++show (i+1)) + --insert $ AssociatedFiles k ("otherfile" ++show (i+2)) - [(k2)] <- select $ from $ \k -> do - where_ (k ^. CachedKeyKey ==. val (show i)) - return (k ^. CachedKeyId) - liftIO $ print (2, k2) - delete $ from $ \f -> do - where_ (f ^. AssociatedFilesKey ==. k2) +query = forM_ [1..1000] $ \i -> do + r <- select $ from $ \(k, f) -> do + where_ (k ^. CachedKeyKey ==. val (show i)) + where_ (f ^. AssociatedFilesKey ==. k ^. CachedKeyId) + return (f ^. AssociatedFilesFile) + liftIO $ print ("got", r) -- cgit v1.2.3