From a9297006f8f4af439404f7d50c5feb5734a1a1ea Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Sat, 10 Sep 2011 06:08:54 -0700 Subject: [PATCH] mongoDB works! --- yesod/Scaffolding/Scaffolder.hs | 7 ++++++- yesod/scaffold/Application.hs.cg | 3 +-- yesod/test/mongodb-input.txt | 4 ++++ yesod/test/run.sh | 8 +++++--- 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 yesod/test/mongodb-input.txt diff --git a/yesod/Scaffolding/Scaffolder.hs b/yesod/Scaffolding/Scaffolder.hs index 3d2c5de8..647dfce5 100644 --- a/yesod/Scaffolding/Scaffolder.hs +++ b/yesod/Scaffolding/Scaffolder.hs @@ -81,6 +81,11 @@ scaffold = do backendLower = uncapitalize $ show backend upper = show backend + let runMigration = + case backend of + MongoDB -> "" + _ -> "\n runConnectionPool (runMigration migrateAll) p" + putStrLn "That's it! I'm creating your files now..." let withConnectionPool = case backend of @@ -93,7 +98,7 @@ scaffold = do Postgresql -> "import Data.Text (Text, pack, concat)\nimport Prelude hiding (concat)" _ -> "import Data.Text (Text, pack)" - packages = if backend == MongoDB then ", mongoDB\n , bson\n" else "" + packages = if backend == MongoDB then ", mongoDB >= 1.1\n , bson >= 0.1.5\n" else "" let fst3 (x, _, _) = x year <- show . fst3 . toGregorian . utctDay <$> getCurrentTime diff --git a/yesod/scaffold/Application.hs.cg b/yesod/scaffold/Application.hs.cg index cb8b1af9..03153b5a 100644 --- a/yesod/scaffold/Application.hs.cg +++ b/yesod/scaffold/Application.hs.cg @@ -47,8 +47,7 @@ getRobotsR = return $ RepPlain $ toContent ("User-agent: *" :: ByteString) with~sitearg~ :: AppConfig -> Logger -> (Application -> IO a) -> IO () with~sitearg~ conf logger f = do s <- static Settings.staticDir - Settings.withConnectionPool conf $ \p -> do - runConnectionPool (runMigration migrateAll) p + Settings.withConnectionPool conf $ \p -> do~runMigration~ let h = ~sitearg~ conf logger s p #ifdef WINDOWS toWaiApp h >>= f >> return () diff --git a/yesod/test/mongodb-input.txt b/yesod/test/mongodb-input.txt new file mode 100644 index 00000000..079224e8 --- /dev/null +++ b/yesod/test/mongodb-input.txt @@ -0,0 +1,4 @@ +Michael +foobar +Foobar +m diff --git a/yesod/test/run.sh b/yesod/test/run.sh index 65719091..948e7689 100755 --- a/yesod/test/run.sh +++ b/yesod/test/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash -ex # # A wrapper for the shelltest test. Passes along options to shelltest. # @@ -10,14 +10,16 @@ cabal clean && cabal install && cabal sdist # this for loop only operates on 1 file (as per tail -1) for f in $(ls -1rt dist/*.tar.gz | tail -1) do - tar -xzvf $f && cd `basename $f .tar.gz` || exit 1 + tar -xzvf $f && cd `basename $f .tar.gz` # shelltest is designed to show you the diff of an expected stdout/stdin. We don't care about that. If it compiles, it compiles # shelltest ../test/scaffold.shelltest --color --diff --all $@ -- --hide-successes ../test/scaffold.sh < ../test/sqlite-input.txt && ../test/scaffold.sh < ../test/postgresql-input.txt && - ../test/scaffold.sh < ../test/tiny-input.txt || (echo "FAILED" && exit 1) + ../test/scaffold.sh < ../test/tiny-input.txt && + ../test/scaffold.sh < ../test/mongodb-input.txt || + (echo "FAILED" && exit 1) cd .. rm -r `basename $f .tar.gz` done