From f60618a7cc227373d4fc0dc8fc98dd2371a09ec5 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Tue, 26 Nov 2024 11:58:46 +0100 Subject: [PATCH 05/10] ob-sql: move functions downwards --- lisp/ob-sql.el | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 9ed695aa8..d20edb9fd 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -150,25 +150,6 @@ (out-file . :any)) "Header arguments accepted.") -(defun org-babel-expand-body:sql (body params) - "Expand BODY according to the values of PARAMS." - (let ((prologue (cdr (assq :prologue params))) - (epilogue (cdr (assq :epilogue params)))) - (mapconcat 'identity - (list - prologue - (org-babel-sql-expand-vars - body (org-babel--get-vars params)) - epilogue) - "\n"))) - -(defun org-babel-edit-prep:sql (info) - "Set `sql-product' in Org edit buffer. -Set `sql-product' in Org edit buffer according to the -corresponding :engine source block header argument." - (let ((product (cdr (assq :engine (nth 2 info))))) - (sql-set-product product))) - (defun org-babel-sql-dbstring-mysql (host port user password database) "Make MySQL cmd line args for database connection. Pass nil to omit that arg." (mapconcat @@ -454,9 +435,25 @@ SET COLSEP '|' (org-babel-pick-name (cdr (assq :rowname-names params)) (cdr (assq :rownames params)))))))) -(defun org-babel-prep-session:sql (_session _params) - "Raise an error because Sql sessions aren't implemented." - (error "SQL sessions not yet implemented")) + +(defun org-babel-edit-prep:sql (info) + "Prepare Org-edit buffer. +Set `sql-product' in Org edit buffer according to +the :engine header argument provided in INFO." + (let ((product (cdr (assq :engine (nth 2 info))))) + (sql-set-product product))) + +(defun org-babel-expand-body:sql (body params) + "Expand BODY according to the values of PARAMS." + (let ((prologue (cdr (assq :prologue params))) + (epilogue (cdr (assq :epilogue params)))) + (mapconcat 'identity + (list + prologue + (org-babel-sql-expand-vars + body (org-babel--get-vars params)) + epilogue) + "\n"))) (defun org-babel-sql-expand-vars (body vars &optional sqlite) "Expand the variables held in VARS in BODY. @@ -487,13 +484,6 @@ argument mechanism." vars) body) -(defun org-babel-prep-session:sql (_session _params) - "Raise an error because Sql sessions aren't implemented." - (message "org-babel-prep-session")) - -(defun org-babel-load-session:sql (session body params) - (message "load session %s" session)) - (defun ob-sql-session-buffer-live-p (buffer) "Return non-nil if the process associated with buffer is live. -- 2.39.5