diff --git a/docs/concepts/insert.rst b/docs/concepts/insert.rst index 640fdef9..c2315a4b 100644 --- a/docs/concepts/insert.rst +++ b/docs/concepts/insert.rst @@ -167,7 +167,7 @@ construct the ``DEFAULT`` expression:: .. warning:: Also note PostgreSQL's syntax rules mean that ``DEFAULT``` can only appear in ``INSERT``` expressions whose rows are specified using ``VALUES``. This - means that the ``rows`` field of your ``Insert`` record doesn't look like + means if that the ``rows`` field of your ``Insert`` record doesn't look like ``values [..]``, then ``unsafeDefault`` won't work. diff --git a/src/Rel8/Expr/Default.hs b/src/Rel8/Expr/Default.hs index 6aa6d3f1..7465d658 100644 --- a/src/Rel8/Expr/Default.hs +++ b/src/Rel8/Expr/Default.hs @@ -27,6 +27,11 @@ import Rel8.Expr.Opaleye ( fromPrimExpr ) -- 3. @DEFAULT@ values can not be transformed. For example, the innocuous Rel8 -- code @unsafeDefault + 1@ will 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 'Rel8.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