return full analysis

This commit is contained in:
Jeremy Penner 2022-03-28 11:27:09 -04:00
parent 0cdcd865c5
commit 837ee0299a

View file

@ -203,7 +203,8 @@
(let [analysis (new-analysis)] (let [analysis (new-analysis)]
(each [_ literal (ipairs [...])] (self:analyze-literal analysis literal)) (each [_ literal (ipairs [...])] (self:analyze-literal analysis literal))
(set analysis.selection (icollect [_ varname (ipairs analysis.variables)] [:as (. analysis.variable-mapping varname) varname])) (set analysis.selection (icollect [_ varname (ipairs analysis.variables)] [:as (. analysis.variable-mapping varname) varname]))
[(.. (self:gen-with-rules analysis) (self:gen-select analysis)) analysis.constants])) (set analysis.query (.. (self:gen-with-rules analysis) (self:gen-select analysis)))
analysis))
(fn Sqlog.insert [self head ...] (fn Sqlog.insert [self head ...]
(match head (match head
@ -215,8 +216,10 @@
(match param (match param
[:var :_] nil [:var :_] nil
expr [:as expr (. columns icolumn)]))) expr [:as expr (. columns icolumn)])))
[(.. (self:gen-with-rules analysis) "INSERT INTO " name " (" (cat analysis.selection ", " #(match $1 [:as _ column] column)) ") " (self:gen-select analysis)) (set analysis.query (.. (self:gen-with-rules analysis)
analysis.constants]) "INSERT INTO " name " (" (cat analysis.selection ", " #(match $1 [:as _ column] column)) ") "
(self:gen-select analysis)))
analysis)
_ (error (.. "Expected literal, got " (fv head))))) _ (error (.. "Expected literal, got " (fv head)))))
(fn Sqlog.delete [self head ...] (fn Sqlog.delete [self head ...]
@ -225,8 +228,8 @@
(let [analysis (new-analysis)] (let [analysis (new-analysis)]
(each [_ literal (ipairs [head ...])] (self:analyze-literal analysis literal)) (each [_ literal (ipairs [head ...])] (self:analyze-literal analysis literal))
(set analysis.selection [[:as [:rowid 1] :_rowid_]]) (set analysis.selection [[:as [:rowid 1] :_rowid_]])
[(.. (self:gen-with-rules analysis) "DELETE FROM " name " WHERE _rowid_ IN (" (self:gen-select analysis) ")") (set analysis.query (.. (self:gen-with-rules analysis) "DELETE FROM " name " WHERE _rowid_ IN (" (self:gen-select analysis) ")"))
analysis.constants]) analysis)
_ (error (.. "Expected literal, got " (fv head))))) _ (error (.. "Expected literal, got " (fv head)))))
(fn Sqlog.update [self newhead head ...] (fn Sqlog.update [self newhead head ...]
@ -239,7 +242,8 @@
(match param (match param
[:var :_] nil [:var :_] nil
expr [:set (. columns icolumn) expr]))) expr [:set (. columns icolumn) expr])))
[(.. (self:gen-with-rules analysis) (self:gen-update analysis)) analysis.constants]))) (set analysis.query (.. (self:gen-with-rules analysis) (self:gen-update analysis)))
analysis)))
Sqlog Sqlog