about summary refs log tree commit diff
path: root/dump
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-06-29 19:44:42 +0300
committerBonfaceKilz2023-07-30 12:29:56 +0300
commitb44b81f070b22c315d381431e39fc80705f11566 (patch)
treea9dcbe0574a11ad037349d2cafcb8a042c257568 /dump
parent32e03d949d5437623ccee0abb00c52189005dcb1 (diff)
downloadgn-transform-databases-b44b81f070b22c315d381431e39fc80705f11566.tar.gz
Add a configuration record-type for for the define macro
* dump/special-forms.scm: Import (srfi srfi-9 gnu).
(<dump-configuration>): New record-type.
(define-dump): Use the above record-type.
Diffstat (limited to 'dump')
-rw-r--r--dump/special-forms.scm23
1 files changed, 21 insertions, 2 deletions
diff --git a/dump/special-forms.scm b/dump/special-forms.scm
index f9dca91..bd1760b 100644
--- a/dump/special-forms.scm
+++ b/dump/special-forms.scm
@@ -1,5 +1,6 @@
 (define-module (dump special-forms)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-9 gnu)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-26)
   #:use-module (dump sql)
@@ -18,8 +19,23 @@
             syntax-let
             blank-node
             map-alist
+            dump-configuration
+            dump-configuration-table-metadata?
+            dump-configuration-auto-document-path
             define-dump))
 
+(define-immutable-record-type <dump-configuration>
+  (%dump-configuration table-metadata? auto-document-path)
+  dump-configuration?
+  (table-metadata? dump-configuration-table-metadata?)
+  (auto-document-path dump-configuration-auto-document-path))
+
+(define* (dump-configuration
+          #:optional (table-metadata? #f)
+          (auto-document-path #f))
+  "Return a new configuration."
+  (%dump-configuration table-metadata? auto-document-path))
+
 (define (key->assoc-ref alist x)
   "Recursively translate (key k) forms in source X to (assoc-ref ALIST
 k) forms."
@@ -377,7 +393,9 @@ must be remedied."
                                                #'(schema-triples)))
                     ((triples subject predicate-clauses ...) (triples)
                      (find-clause #'(clauses ...) 'triples)))
-         #`(define* (name db #:optional (table-metadata? #f))
+         #`(define* (name db
+                          #:optional (dump-configuration
+                                      (dump-configuration)))
              #,(syntax-case #'schema-triples-clause (schema-triples)
                  ((schema-triples (triple-subject triple-predicate triple-object) ...)
                   #`(for-each triple
@@ -385,7 +403,8 @@ must be remedied."
                               (list 'triple-predicate ...)
                               (list 'triple-object ...)))
                  (_ (error "Invalid schema triples clause:" #'schema-triples-clause)))
-             (when table-metadata?
+             (when (dump-configuration-table-metadata?
+                    dump-configuration)
                #,@(let ((dump-table (symbol->string (syntax->datum #'primary-table)))
                         (subject-type (any (lambda (predicate)
                                              (syntax-case predicate (rdf:type)