emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Nick Savage <nick@nicksavage.ca>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Reduce code duplication in ob-sql.el and ob-sqlite.el
Date: Thu, 04 Mar 2021 00:25:12 -0500	[thread overview]
Message-ID: <87eegvcwxz.fsf@kyleam.com> (raw)
In-Reply-To: <0766206a-5df8-8d95-e6fd-2f96f06c9840@nicksavage.ca>

Nick Savage writes:

> Hi everyone,
> See the attached patch. It is a small change to reduce code duplication 
> between ob-sql.el and ob-sqlite.el by reusing org-babel-sql-expand-vars 
> as suggested by the FIXME in ob-sqlite.el.

Thank you.  Looks good, though I think it'd be nice to keep
org-babel-sqlite-expand-vars around for a bit, marked as obsolete.

> Subject: [PATCH] Reduce code duplication in ob-sqlite.el and ob-sql.el
> * lisp/ob-sqlite.el (org-babel-sqlite-expand-vars): removed function
> to replace with ob-sql.el version
> * lisp/ob-sql.el (org-babel-sql-expand-vars): updated to support
> expanding sqlite vars

Please capitalize the first word after ":" and end the entries with a


> -(defun org-babel-sqlite-expand-vars (body vars)
> -  "Expand the variables held in VARS in BODY."
> -  ;; FIXME: Redundancy with org-babel-sql-expand-vars!
> -  (mapc
> -   (lambda (pair)
> -     (setq body
> -	   (replace-regexp-in-string
> -	    (format "$%s" (car pair))
> -	    (let ((val (cdr pair)))
> -              (if (listp val)
> -                  (let ((data-file (org-babel-temp-file "sqlite-data-")))
> -                    (with-temp-file data-file
> -                      (insert (orgtbl-to-csv val nil)))
> -                    data-file)
> -                (if (stringp val) val (format "%S" val))))
> -	    body)))
> -   vars)
> -  body)
> -

How about marking this with (declare (obsolete ...)) and keeping it
around as a wrapper that calls org-babel-sql-expand-vars?  That will
give any third-party code that may have used this for whatever reason
(perhaps unlikely) a chance to update.

  reply	other threads:[~2021-03-04  5:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 13:16 [PATCH] Reduce code duplication in ob-sql.el and ob-sqlite.el Nick Savage
2021-03-04  5:25 ` Kyle Meyer [this message]
2021-03-04 12:55   ` Nick Savage
2021-03-09  5:51     ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eegvcwxz.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=nick@nicksavage.ca \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).