Skip to content

Commit

Permalink
Expand documentation on unsafeDefault
Browse files Browse the repository at this point in the history
This copies the documentation in the cookbook to the haddocks,
addressing #233.
  • Loading branch information
abigailalice committed Mar 16, 2024
1 parent 9c6e6d7 commit 3fbaebd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/concepts/insert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
5 changes: 5 additions & 0 deletions src/Rel8/Expr/Default.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3fbaebd

Please sign in to comment.