diff options
author | Munyoki Kilyungi | 2023-07-06 15:21:10 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2023-07-21 14:36:37 +0300 |
commit | be9fd2b2744daa1c9b683dde2909ac01e85f37e7 (patch) | |
tree | 487a5188cb3537a5f78b5a98b037b12b70f3d56a /dump | |
parent | 10bebdf9f9618b96c75ffdc1b197bde639ec8421 (diff) | |
download | gn-transform-databases-be9fd2b2744daa1c9b683dde2909ac01e85f37e7.tar.gz |
Print out triples with the from Table.Name or Table.Alias
* dump/special-forms.scm (field->datum): New function.
(define-dump): Use the field->datum to convert triples into the form
Table.Name or Table.Alias.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'dump')
-rw-r--r-- | dump/special-forms.scm | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/dump/special-forms.scm b/dump/special-forms.scm index 727b356..2281f23 100644 --- a/dump/special-forms.scm +++ b/dump/special-forms.scm @@ -223,7 +223,24 @@ Example: -(eval-when (expand load eval) +(eval-when (expand load ) + (define (field->datum x) + (translate-forms + 'field + (lambda (x) + (syntax-case x (field) + ((field (query alias)) + #`(format #f "~a" (syntax->datum #'alias))) + ((field table column) + #`(format #f "~a.~a" + (syntax->datum #'table) + (syntax->datum #'column))) + ((field table column alias) + #`(format #f "~a.~a" + (syntax->datum table) + (syntax->datum alias))))) + x)) + (define (field->key x) (translate-forms 'field (lambda (x) @@ -477,30 +494,14 @@ Triples take the form: (for-each (match-lambda ((predicate . object) (format out "~a -> ~a -> ~a ~%" - #,(car (collect-keys - (field->key #'subject))) + #,(field->datum #'subject) predicate object))) (map-alist '() - #,@(translate-forms 'field - (lambda (x) - (syntax-case x (field) - ((field (query alias)) - #`(format #f "~a" (syntax->datum #'alias))) - ((field table column) - #`(format #f "~a.~a" - (syntax->datum #'table) - (syntax->datum #'column))) - ((field table column alias) - #`(format #f "~a.~a" - (syntax->datum table) - (syntax->datum alias))))) - #'(predicate-clauses ...))) - ) + #,@(field->datum #'subject))) (format out "~%") ;; To clear the buffer - (force-output out) - )) + (force-output out))) (when (dump-configuration-triples? dump-configuration) (sql-for-each (lambda (row) (scm->triples |