Fixes.
diff --git a/Blog/Blog b/Blog/Blog
index 477f542..9ad5878 100755
Binary files a/Blog/Blog and b/Blog/Blog differ
diff --git a/Blog/Config.hs b/Blog/Config.hs
index a1d6d89..de23091 100644
--- a/Blog/Config.hs
+++ b/Blog/Config.hs
@@ -8,11 +8,11 @@ params = HP { docdir = "static",
-- dbDriver = "sqlite3",
dbDriver = "psql",
-- dbPath = "blog.db",
- dbPath = "host=rtfm-server password=31415",
+ dbPath = "host=localhost password=31415",
-- cacheDriver = "memcached",
-- cachePath = "localhost:11211",
--- cacheDriver = "fake",
- cacheDriver = "filesystem",
+ cacheDriver = "fake",
+-- cacheDriver = "filesystem",
cachePath = "tmp/",
sessionsDriver = "files",
sessionsPath = "tmp/sessions/"
diff --git a/Framework/API.hs b/Framework/API.hs
index 6291ca7..3e31ca8 100644
--- a/Framework/API.hs
+++ b/Framework/API.hs
@@ -29,6 +29,8 @@ import Framework.Models (Model)
import Framework.Http.Response ((<+>))
import Framework.Http.HTTPServer (serveHttp,serveStatic)
+trace' x = trace (show x) x
+
----------------------------------------------------------------------------------------------------------
-- * Sessions API
@@ -73,7 +75,7 @@ commit ac = Storage.commit (dbconnection ac)
-- | Same as "queryList", but gets SQL.Query instead of plain SQL
queryListSQL :: ActionConfig -> SQL.Query -> [HDBC.SqlValue] -> IO [[HDBC.SqlValue]]
-queryListSQL ac q params = Storage.query (dbconnection ac) (trace (SQL.sql q) (SQL.sql q)) params
+queryListSQL ac q params = Storage.query (dbconnection ac) (SQL.sql q) params
-- | Same, but strict.
queryListSQL' :: ActionConfig -> SQL.Query -> [HDBC.SqlValue] -> IO [[HDBC.SqlValue]]
diff --git a/Framework/SQL.hs b/Framework/SQL.hs
index 13989a6..2a53493 100644
--- a/Framework/SQL.hs
+++ b/Framework/SQL.hs
@@ -137,7 +137,8 @@ liftF fn (QField name) = QFn fn name
liftF fn (QFn _ name) = QFn fn name
-- | Get `count` function of query
-count = flip aggregate "count"
+count q@(Query flds tbls conds ordr grp lim) | TableJoin lst <- tbls = Query [liftF "count" $ head flds] (TableList [head lst]) NoCondition [] [] Nothing
+ | otherwise = aggregate q "count"
allFields = [QField "*"]
@@ -191,7 +192,7 @@ getForeignKey m = fkey (mFields m)
-- | SELECT all items in table and, for each item, count it's subitems
countChildren :: Model -> Model -> String -> Query
-countChildren m c ord = count $ setFields fs $ ((table m) `joinT` childTable)
+countChildren m c ord = (flip aggregate "count") $ setFields fs $ ((table m) `joinT` childTable)
`restrict` ((childTable++"."++childId) :==: parentField)
`sgroup` (parentField++", "++ordField) `order` (Asceding ordField)
where childTable = mTable c
diff --git a/Framework/Utils.hs b/Framework/Utils.hs
index 0e67ee3..9670e1a 100644
--- a/Framework/Utils.hs
+++ b/Framework/Utils.hs
@@ -109,7 +109,7 @@ lazySlurp fp ix len
cs <- unsafeInterleaveIO (lazySlurp fp (ix + buf_size) len)
ws <- withForeignPtr fp $ \p -> loop (min (len-ix) buf_size - 1)
((p :: Ptr Word8) `plusPtr` ix) cs
- return ws
+ return $ decodeString ws
where
loop :: Int -> Ptr Word8 -> String -> IO String
loop len p acc