diff options
| author | Marius Peter <dev@marius-peter.com> | 2025-11-01 18:07:45 +0100 | 
|---|---|---|
| committer | Marius Peter <dev@marius-peter.com> | 2025-11-01 18:07:45 +0100 | 
| commit | 7fcdf1c402ea3db38147d1aa12eb5b9bd5b3e592 (patch) | |
| tree | 866b2ea40d9e7f7d447634947c6ac8d16ad291aa /models/nutrient.rkt | |
| parent | 1f3aad4a542981d1681989accdfcf5bad38b8b2c (diff) | |
Realign nutrient creation function.
Diffstat (limited to 'models/nutrient.rkt')
| -rw-r--r-- | models/nutrient.rkt | 14 | 
1 files changed, 6 insertions, 8 deletions
diff --git a/models/nutrient.rkt b/models/nutrient.rkt index 8d38f74..6df0989 100644 --- a/models/nutrient.rkt +++ b/models/nutrient.rkt @@ -31,14 +31,12 @@  ;; CREATE  (define (create-nutrient! name formula) -  (define existing-nutrient (get-nutrient #:name name #:formula formula)) -  (define (new-nutrient) -    (query-exec (current-conn) -                (insert #:into nutrients -                        #:set [canonical_name ,name] [formula ,formula])) -    (get-nutrient #:name name)) -  (or existing-nutrient -      (new-nutrient))) +  (or (get-nutrient #:name name #:formula formula) +      (begin +        (query-exec (current-conn) +                    (insert #:into nutrients +                            #:set [canonical_name ,name] [formula ,formula])) +        (get-nutrient #:name name))))  ;; READ  |