| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Rel8.Internal.Expr.Default
Synopsis
- unsafeDefault :: Expr a
Documentation
unsafeDefault :: Expr a Source #
Corresponds to the SQL DEFAULT expression.
This Expr is unsafe for numerous reasons, and should be used with care:
- This
Expronly makes sense in anINSERTorUPDATEstatement. - Rel8 is not able to verify that a particular column actually has a
DEFAULTvalue. Trying to useunsafeDefaultwhere there is no default will cause a runtime crash DEFAULTvalues cannot be transformed. For example, the innocuous Rel8 codeunsafeDefault + 1will crash, despite type checking.
Also note, PostgreSQL's syntax rules mean that DEFAULT can only appear in
INSERT expressions whose rows are specified using VALUES. This means
that if the rows field of your Insert record doesn't look like
values [..], then unsafeDefault won't work.
Given all these caveats, we suggest avoiding the use of default values where
possible, instead being explicit. A common scenario where default values are
used is with auto-incrementing identifier columns. In this case, we suggest
using nextval instead.