guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

11/18: Improve some query formatting


From: Christopher Baines
Subject: 11/18: Improve some query formatting
Date: Mon, 16 Dec 2024 04:02:41 -0500 (EST)

cbaines pushed a commit to branch master
in repository data-service.

commit 5664cde17cfd8acbdfcea8ebe1d364ed287c9e5a
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sat Dec 7 12:30:04 2024 +0000

    Improve some query formatting
---
 guix-data-service/model/utils.scm | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/guix-data-service/model/utils.scm 
b/guix-data-service/model/utils.scm
index 0c2cb72..cd59681 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -277,22 +277,20 @@ JOIN (VALUES "
   (define query
     (string-append
      "
-INSERT INTO " table-name " (\n"
-(string-join field-strings ",\n")
-") VALUES "
-(string-join
- (map (lambda (field-values)
-        (string-append
-         "("
-         (string-join
-          (map (lambda (value)
-                 (value->sql value))
-               field-values)
-          ", ")
-         ")"))
-      data)
- ", ")
-" ON CONFLICT DO NOTHING
+INSERT INTO " table-name " (" (string-join field-strings ", ") ") VALUES
+" (string-join
+   (map (lambda (field-values)
+          (string-append
+           "("
+           (string-join
+            (map (lambda (value)
+                   (value->sql value))
+                 field-values)
+            ", ")
+           ")"))
+        data)
+   ", ") "
+ON CONFLICT DO NOTHING
 RETURNING id"))
 
   (if (null? data)
@@ -428,7 +426,7 @@ WHERE "
   (define insert
     (string-append
      "
-INSERT INTO " table-name " (\n" (string-join field-strings ",\n") ")
+INSERT INTO " table-name " (" (string-join field-strings ", ") ")
 VALUES (" (string-join
            (map (lambda (i)
                   (simple-format #f "$~A" i))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]