From e473261dd22f96937ede4f37e62a88ea62c95112 Mon Sep 17 00:00:00 2001 From: Marc Scholten Date: Wed, 13 Oct 2021 12:01:05 +0200 Subject: [PATCH] Fixed Data Editor turning NULL values into empty strings when editing a row. Fixes #978 --- IHP/IDE/Data/View/EditRow.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/IHP/IDE/Data/View/EditRow.hs b/IHP/IDE/Data/View/EditRow.hs index d6b7aac49..ce7ff4468 100644 --- a/IHP/IDE/Data/View/EditRow.hs +++ b/IHP/IDE/Data/View/EditRow.hs @@ -187,7 +187,7 @@ instance View EditRowView where id={get #columnName def <> "-sqlbox"} type="checkbox" name={get #columnName def <> "_"} - checked={isSqlFunction_ (value val)} + checked={isSQLMode} class="mr-1" onclick={"sqlModeCheckbox('" <> get #columnName def <> "', this)"} /> @@ -200,5 +200,11 @@ instance View EditRowView where /> |] + where + isNull = isNothing (get #fieldValue val) + isSQLMode = isSqlFunction_ (value val) || isNull -value val = fromMaybe BS.empty (get #fieldValue val) \ No newline at end of file +value :: DynamicField -> ByteString +value dynamicField = case get #fieldValue dynamicField of + Just string -> string + Nothing -> "NULL"