diff --git a/apiary-persistent.cabal b/apiary-persistent.cabal
--- a/apiary-persistent.cabal
+++ b/apiary-persistent.cabal
@@ -1,5 +1,5 @@
 name:                apiary-persistent
-version:             0.12.0
+version:             0.13.0
 synopsis:            persistent support for apiary web framework.
 description:
   example: <https://github.com/philopon/apiary/blob/master/examples/persistent.hs>
@@ -21,12 +21,13 @@
   other-modules:       
   build-depends:       base               >=4.6   && <4.8
                      , persistent         >=1.3   && <1.4
-                     , apiary             >=0.12  && <0.13
+                     , apiary             >=0.13  && <0.14
                      , monad-logger       >=0.3   && <0.4
                      , resourcet          >=1.1   && <1.2
                      , mtl                >=2.1   && <2.3
-                     , reflection         >=1.4   && <1.5
+                     , reflection         >=1.4   && <1.6
                      , transformers-base  >=0.4   && <0.5
+                     , blaze-html         >=0.7   && <0.8
 
   hs-source-dirs:      src
   ghc-options:         -O2 -Wall
diff --git a/src/Web/Apiary/Database/Persist.hs b/src/Web/Apiary/Database/Persist.hs
--- a/src/Web/Apiary/Database/Persist.hs
+++ b/src/Web/Apiary/Database/Persist.hs
@@ -4,6 +4,7 @@
 {-# LANGUAGE ConstraintKinds #-}
 {-# LANGUAGE KindSignatures #-}
 {-# LANGUAGE TypeFamilies #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 module Web.Apiary.Database.Persist (
     -- * runner
@@ -24,12 +25,17 @@
     ) where
 
 import Database.Persist.Sql
+
 import Web.Apiary
+
 import Control.Applicative
 import Control.Monad.Trans.Resource
+import Control.Monad.Apiary.Filter.Internal
+
+import Text.Blaze.Html
 import Data.Reflection
 import Data.Apiary.SList
-import Control.Monad.Apiary.Filter.Internal
+import Data.Apiary.Document
 
 type HasPersist = Given Persist
 
@@ -60,9 +66,10 @@
 
 -- | filter by sql query. since 0.9.0.0.
 sql :: (BoolLike a, Functor n, Monad n, MonadBaseControl IO (ActionT n), HasPersist)
-    => SqlPersistT (ResourceT (ActionT n)) a
+    => Maybe Html 
+    -> SqlPersistT (ResourceT (ActionT n)) a
     -> ApiaryT (Snoc as (UnBool a)) n m b
     -> ApiaryT as n m b
-sql p = focus id $ \l -> do
+sql doc p = focus (maybe id DocPrecondition doc) $ \l -> do
     r <- runSql p
     maybe empty (\i -> return $ sSnoc l i) $ unBool r
