On Sun, Apr 7, 2019 at 9:24 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> 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.


--