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