aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdump.scm7
-rw-r--r--dump/sql.scm4
2 files changed, 8 insertions, 3 deletions
diff --git a/dump.scm b/dump.scm
index 112086b..b05af85 100755
--- a/dump.scm
+++ b/dump.scm
@@ -134,6 +134,7 @@ association list mapping substrings to their replacements."
#`(key #,(symbol->string
(syntax->datum
((syntax-rules (field)
+ ((field (query alias)) alias)
((field table column) column)
((field table column alias) alias)
((field table column operation alias) alias))
@@ -149,6 +150,7 @@ ALIST field-name) forms."
#,(symbol->string
(syntax->datum
((syntax-rules (field)
+ ((field (query alias)) alias)
((field table column) column)
((field table column alias) alias)
((field table column operation alias) alias))
@@ -311,7 +313,10 @@ must be remedied."
((table-name column-name _ ...)
(datum->syntax
x (column-id (symbol->string table-name)
- (symbol->string column-name))))))
+ (symbol->string column-name))))
+ (((query alias))
+ (datum->syntax
+ x (column-id query (symbol->string alias))))))
(collect-fields predicate-clause))))
#,(dump-id dump-table (syntax->datum #'predicate)))
;; Automatically create domain triples
diff --git a/dump/sql.scm b/dump/sql.scm
index 54371a2..76c9e0e 100644
--- a/dump/sql.scm
+++ b/dump/sql.scm
@@ -29,12 +29,12 @@
(_ ""))
#,(string-join (filter-map (match-lambda
('distinct #f)
+ (((query alias))
+ (format #f "~a AS ~a" query alias))
((table column)
(format #f "~a.~a" table column))
((table column alias)
(format #f "~a.~a AS ~a" table column alias))
- ((table column operation alias)
- (format #f "~a(~a.~a) AS ~a" operation table column alias))
(field-spec
(error "Invalid field specification" field-spec)))
(syntax->datum #'fields))