summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <dev@marius-peter.com>2025-11-02 19:41:25 +0100
committerMarius Peter <dev@marius-peter.com>2025-11-02 19:41:25 +0100
commitd193f463088d2e120f5e236afd0ddfda8e30c6d8 (patch)
tree98bb758163a75292c554b1c392f3bc08cd7c7f5e
parent1b23eec4517a8628a9564c9ed25923e6c9ea5bd8 (diff)
Add guard function to prevent null SQL values from leaking out.
-rw-r--r--models/fertilizer-product.rkt6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/fertilizer-product.rkt b/models/fertilizer-product.rkt
index 0a6c03d..b93f082 100644
--- a/models/fertilizer-product.rkt
+++ b/models/fertilizer-product.rkt
@@ -32,6 +32,12 @@
;; Instances of this struct are persisted in the fertilizer_products table.
(struct fertilizer-product (id canonical-name nutrient-values brand-name)
#:transparent
+ #:guard
+ (λ (id canonical-name nutrient-values brand-name _)
+ (values id
+ canonical-name
+ nutrient-values
+ (if (sql-null? brand-name) #f brand-name)))
#:property prop:custom-write
(λ (v out _mode)
(fprintf out "Fertilizer #~a\n" (fertilizer-product-id v))
Copyright 2019--2025 Marius PETER