aboutsummaryrefslogtreecommitdiff
path: root/fooes.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-02-15 13:54:04 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-02-15 14:02:39 -0400
commit1a8e94e85977bd4d3781082b37186f6319309631 (patch)
treeb5d146ceb751c7850513803615265e74d10c064c /fooes.hs
parent2bf34f967a1512cc4c3a315cc0436170face7105 (diff)
update, fixing compilation and fixing to actually do a join
Diffstat (limited to 'fooes.hs')
-rw-r--r--fooes.hs22
1 files changed, 14 insertions, 8 deletions
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)