From 9c6e6d7cf26769ab708dfc210e5b4ce28d94715b Mon Sep 17 00:00:00 2001 From: Abigail Gooding Date: Thu, 14 Mar 2024 13:41:32 -0700 Subject: [PATCH 1/3] Fix some unescaped markup in haddocks This addresses #315 --- src/Rel8.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Rel8.hs b/src/Rel8.hs index 632bd593..20921c48 100644 --- a/src/Rel8.hs +++ b/src/Rel8.hs @@ -563,9 +563,9 @@ import Rel8.Window -- query = do -- thingExpr <- each thingSchema -- where_ $ --- deconstructADT @Thing --- (\employer -> employerName employer ==. lit \"Mary\") --- (\potato -> grower potato ==. lit \"Mary\") +-- deconstructADT \@Thing +-- (\\employer -> employerName employer ==. lit \"Mary\") +-- (\\potato -> grower potato ==. lit \"Mary\") -- (lit False) -- Nullary case -- thingExpr -- pure thingExpr @@ -609,10 +609,10 @@ import Rel8.Window -- instantiations of 'buildADT' for 'Task': -- -- @ --- > :t buildADT @Task @\"Pending\" --- buildADT @Task @\"Pending\" :: ADT Task Expr --- > :t buildADT @Task @\"Complete\" --- buildADT @Task @\"Complete\" :: CompletedTask Expr -> ADT Task Expr +-- > :t buildADT \@Task \@\"Pending\" +-- buildADT \@Task \@\"Pending\" :: ADT Task Expr +-- > :t buildADT \@Task @\"Complete\" +-- buildADT \@Task \@\"Complete\" :: CompletedTask Expr -> ADT Task Expr -- @ -- -- Note that as the "Pending" constructor has no fields, @buildADT @@ -635,8 +635,8 @@ import Rel8.Window -- @ -- > :{ -- showQuery $ values --- [ buildADT @Task @\"Pending\" --- , buildADT @Task @\"Complete\" CompletedTask {date = Rel8.Expr.Time.now} +-- [ buildADT \@Task \@\"Pending\" +-- , buildADT \@Task \@\"Complete\" CompletedTask {date = Rel8.Expr.Time.now} -- ] -- :} -- @ @@ -685,10 +685,10 @@ import Rel8.Window -- @ -- let -- pending :: ADT Task Expr --- pending = constructADT @Task $ \pending _complete -> pending +-- pending = constructADT \@Task $ \\pending _complete -> pending -- -- complete :: ADT Task Expr --- complete = constructADT @Task $ \_pending complete -> complete CompletedTask {date = Rel8.Expr.Time.now} +-- complete = constructADT \@Task $ \\_pending complete -> complete CompletedTask {date = Rel8.Expr.Time.now} -- @ -- -- These values are otherwise identical to the ones we saw above with From 3fbaebd61cd8ce1b0010bce3a9811c370559d06f Mon Sep 17 00:00:00 2001 From: Abigail Gooding Date: Sat, 16 Mar 2024 07:53:56 -0700 Subject: [PATCH 2/3] Expand documentation on unsafeDefault This copies the documentation in the cookbook to the haddocks, addressing #233. --- docs/concepts/insert.rst | 2 +- src/Rel8/Expr/Default.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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 From d6d7ca2973e6f9072346f85773880c2caad3d88f Mon Sep 17 00:00:00 2001 From: abigailalice <95150492+abigailalice@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:55:41 -0700 Subject: [PATCH 3/3] Update docs/concepts/insert.rst Co-authored-by: Ollie Charles --- docs/concepts/insert.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/concepts/insert.rst b/docs/concepts/insert.rst index c2315a4b..4e729712 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 if that the ``rows`` field of your ``Insert`` record doesn't look like + means that if the ``rows`` field of your ``Insert`` record doesn't look like ``values [..]``, then ``unsafeDefault`` won't work.