diff options
author | Munyoki Kilyungi | 2023-06-29 19:44:42 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2023-07-21 14:36:35 +0300 |
commit | 31825be584da4108d0984a310e8c301516d9bb4f (patch) | |
tree | a9dcbe0574a11ad037349d2cafcb8a042c257568 /dump | |
parent | 32e03d949d5437623ccee0abb00c52189005dcb1 (diff) | |
download | gn-transform-databases-31825be584da4108d0984a310e8c301516d9bb4f.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.scm | 23 |
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) |