emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] ob-sql.el: Option to reference connections in `sql-conne


From: Stefano Rodighiero
Subject: Re: [O] [PATCH] ob-sql.el: Option to reference connections in `sql-connection-alist'
Date: Sun, 14 Apr 2019 16:25:21 +0200

On Sun, Apr 7, 2019 at 9:24 AM Nicolas Goaziou <address@hidden> wrote:

Thank you for your review.
I am attaching a new patch that should address your remarks.
Also, see comments below.
 
> +Given a param NAME, if :dbconnection is defined in PARAMS then
> +look for the param into the corresponding connection defined in
> +`sql-connection-alist`, otherwise look into PARAMS.  Look
> +`sql-connection-alist` (part of SQL mode) for how to define
> +database connections."
> +  (if (assq :dbconnection params)
> +      (let* ((dbconnection (cdr (assq :dbconnection params)))
> +             (name-mapping '((dbhost . sql-server)
> +                             (dbport . sql-port)
> +                             (dbuser . sql-user)
> +                             (dbpassword . sql-password)
> +                             (database . sql-database)))
> +             (mapped-name (cdr (assq name name-mapping))))
> +        (cadr (assq mapped-name
> +                    (cdr (assoc dbconnection
> +                                sql-connection-alist)))))
> +    (cdr (assq name params))))

Isn't there a type mismatch here?

I think you are talking about the asymmetry of `cdr' and `cadr'
in the two branches of `if'.
Unfortunately, it's what I need to access `sql-connection-alist'.
This custom's name is IMO a bit misleading. Here a passage 
from its documentation: 

'''
Each element of the alist is as follows:

  (CONNECTION \(SQL-VARIABLE VALUE) ...)
'''

And here a piece of code from `sql-connect' as defined
in sql.el (here, connect-set is the set of options attached
to a particular connection):

'''
(dolist (vv connect-set)
                  (let ((var (car vv))
                        (val (cadr vv)))
                    (set-default var (eval val))))
'''

regards,
s.


--

Attachment: 0001-ob-sql.el-Option-to-reference-connections-in-sql-con.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]