diff --git a/Database/Groundhog/TH/CodeGen.hs b/Database/Groundhog/TH/CodeGen.hs
--- a/Database/Groundhog/TH/CodeGen.hs
+++ b/Database/Groundhog/TH/CodeGen.hs
@@ -464,7 +464,7 @@
     (lastPrims, fields) <- spanM (isPrim . snd) $ reverse vars
     let lastPrims' = map (\(x, _) -> [| toPrimitivePersistValue $(varE proxy) $(varE x) |]) $ reverse $ lastPrims
     let body = if null fields
-        then [| return $ ($(listE $ [|toPrimitivePersistValue $(varE proxy) (cNum :: Int)|]:lastPrims')++) |]
+        then [| return $ ($(listE $ [|toPrimitivePersistValue $(varE proxy) $(lift (cNum :: Int))|]:lastPrims')++) |]
         else do
           let go (m, f) (fname, t) = isPrim t >>= \isP -> if isP
               then return (m, [| (toPrimitivePersistValue $(varE proxy) $(varE fname):) |]:f)
@@ -472,7 +472,7 @@
           (stmts, func) <- foldM go ([], []) fields        -- foldM puts reversed fields in normal order
           let nonPrimFields' = foldr1 (\a b -> [|$a . $b|]) func
           let result = if null lastPrims' then nonPrimFields' else [| $nonPrimFields' . ($(listE lastPrims')++) |]
-          doE $ stmts ++ [noBindS [| return $ (toPrimitivePersistValue $(varE proxy) (cNum :: Int):) . $result |]]
+          doE $ stmts ++ [noBindS [| return $ (toPrimitivePersistValue $(varE proxy) $(lift (cNum :: Int)):) . $result |]]
     let body' = [| phantomDb >>= $(lamE [varP proxy] body) |]
     clause [pat] (normalB body') []
 
diff --git a/groundhog-th.cabal b/groundhog-th.cabal
--- a/groundhog-th.cabal
+++ b/groundhog-th.cabal
@@ -1,5 +1,5 @@
 name:            groundhog-th
-version:         0.3.0
+version:         0.3.0.1
 license:         BSD3
 license-file:    LICENSE
 author:          Boris Lykah <lykahb@gmail.com>
