From d9968f9924797508a9b85adeec3c249411d2bf11 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Tue, 26 Nov 2024 11:38:28 +0100 Subject: [PATCH 02/10] ob-sql: re-align to improve readability --- lisp/ob-sql.el | 87 +++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 24870b354..9e55d6d13 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -86,15 +86,15 @@ (defvar org-babel-default-header-args:sql '()) (defconst org-babel-header-args:sql - '((engine . :any) - (out-file . :any) - (dbhost . :any) - (dbport . :any) - (dbuser . :any) - (dbpassword . :any) - (dbinstance . :any) - (database . :any)) - "SQL-specific header arguments.") + '((engine . :any) + (dbhost . :any) + (dbport . :any) + (dbuser . :any) + (dbpassword . :any) + (dbinstance . :any) + (database . :any) + (out-file . :any)) + "Header arguments accepted.") (defun org-babel-expand-body:sql (body params) "Expand BODY according to the values of PARAMS." @@ -167,52 +167,53 @@ using its alias." "Make sqlcmd command line args for database connection. `sqlcmd' is the preferred command line tool to access Microsoft SQL Server on Windows and Linux platform." - (mapconcat #'identity - (delq nil - (list (when host (format "-S \"%s\"" (shell-quote-argument host))) - (when user (format "-U \"%s\"" (shell-quote-argument user))) - (when password (format "-P \"%s\"" (shell-quote-argument password))) - (when database (format "-d \"%s\"" (shell-quote-argument database))))) - " ")) + (mapconcat + #'identity + (delq nil + (list (when host (format "-S \"%s\"" (shell-quote-argument host))) + (when user (format "-U \"%s\"" (shell-quote-argument user))) + (when password (format "-P \"%s\"" (shell-quote-argument password))) + (when database (format "-d \"%s\"" (shell-quote-argument database))))) + " ")) (defun org-babel-sql-dbstring-sqsh (host user password database) "Make sqsh command line args for database connection. \"sqsh\" is one method to access Sybase or MS SQL via Linux platform" - (mapconcat #'identity - (delq nil - (list (when host (format "-S \"%s\"" (shell-quote-argument host))) - (when user (format "-U \"%s\"" (shell-quote-argument user))) - (when password (format "-P \"%s\"" (shell-quote-argument password))) - (when database (format "-D \"%s\"" (shell-quote-argument database))))) - " ")) + (mapconcat + #'identity + (delq nil + (list (when host (format "-S \"%s\"" (shell-quote-argument host))) + (when user (format "-U \"%s\"" (shell-quote-argument user))) + (when password (format "-P \"%s\"" (shell-quote-argument password))) + (when database (format "-D \"%s\"" (shell-quote-argument database))))) + " ")) (defun org-babel-sql-dbstring-vertica (host port user password database) "Make Vertica command line args for database connection. Pass nil to omit that arg." - (mapconcat #'identity - (delq nil - (list (when host (format "-h %s" (shell-quote-argument host))) - (when port (format "-p %d" port)) - (when user (format "-U %s" (shell-quote-argument user))) - (when password (format "-w %s" (shell-quote-argument password) )) - (when database (format "-d %s" (shell-quote-argument database))))) - " ")) + (mapconcat + #'identity + (delq nil + (list (when host (format "-h %s" (shell-quote-argument host))) + (when port (format "-p %d" port)) + (when user (format "-U %s" (shell-quote-argument user))) + (when password (format "-w %s" (shell-quote-argument password) )) + (when database (format "-d %s" (shell-quote-argument database))))) + " ")) (defun org-babel-sql-dbstring-saphana (host port instance user password database) "Make SAP HANA command line args for database connection. Pass nil to omit that arg." - (mapconcat #'identity - (delq nil - (list (and host port (format "-n %s:%s" - (shell-quote-argument host) - port)) - (and host (not port) (format "-n %s" (shell-quote-argument host))) - (and instance (format "-i %d" instance)) - (and user (format "-u %s" (shell-quote-argument user))) - (and password (format "-p %s" - (shell-quote-argument password))) - (and database (format "-d %s" (shell-quote-argument database))))) - " ")) + (mapconcat + #'identity + (delq nil + (list (and host port (format "-n %s:%s" (shell-quote-argument host) port)) + (and host (not port) (format "-n %s" (shell-quote-argument host))) + (and instance (format "-i %d" instance)) + (and user (format "-u %s" (shell-quote-argument user))) + (and password (format "-p %s" (shell-quote-argument password))) + (and database (format "-d %s" (shell-quote-argument database))))) + " ")) (defun org-babel-sql-convert-standard-filename (file) "Convert FILE to OS standard file name. -- 2.39.5