1module Rel8.Expr.Default
10import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
13import Rel8.Expr ( Expr )
14import Rel8.Expr.Opaleye ( fromPrimExpr )
17-- | Corresponds to the SQL @DEFAULT@ expression.
19-- This 'Expr' is unsafe for numerous reasons, and should be used with care:
21-- 1. This 'Expr' only makes sense in an @INSERT@ or @UPDATE@ statement.
23-- 2. Rel8 is not able to verify that a particular column actually has a
24-- @DEFAULT@ value. Trying to use @unsafeDefault@ where there is no default
25-- will cause a runtime crash
27-- 3. @DEFAULT@ values can not be transformed. For example, the innocuous Rel8
28-- code @unsafeDefault + 1@ will crash, despite type checking.
30-- Given all these caveats, we suggest avoiding the use of default values where
31-- possible, instead being explicit. A common scenario where default values are
32-- used is with auto-incrementing identifier columns. In this case, we suggest
33-- using 'Rel8.nextval' instead.
34unsafeDefault :: Expr a
35unsafeDefault = fromPrimExpr Opaleye.DefaultInsertExpr
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list