emacs-devel
[Top][All Lists]
Advanced

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

Re: Patch for sql.el (quote table names in sql-list-table)


From: Matthew Carter
Subject: Re: Patch for sql.el (quote table names in sql-list-table)
Date: Thu, 28 Jan 2016 21:55:39 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

"Michael R. Mauger" <address@hidden> writes:

> I'd discourage this change. The List Tables prompt does not prevent use of
> identifier enclosing characters and by not using them you get the default
> case conversion behavior. There are also cases with MS SQL Server where the
> enclosing character is not a single character but rather a [ and ] pair.
>
> I'd also be concerned when I ask to list the table in another schema since
> we'd now be enclosing the schema and table name within the quotes which is
> clearly not what we want.
>
>
>
> --
> View this message in context: 
> http://emacs.1067599.n5.nabble.com/Patch-for-sql-el-quote-table-names-in-sql-list-table-tp385543p385599.html
> Sent from the Emacs - Dev mailing list archive at Nabble.com.
>

The original problem/issue I had with this arised from the following
function in sql.el (the one that generates the postgres completion
candidate list):

(defun sql-postgres-completion-object (sqlbuf schema)

....<snip>....

      ;; Return the list of table names (public schema name can be omitted)
      (mapcar #'(lambda (tbl)
                  (if (string= (car tbl) "public")
                      (cadr tbl)
                    (format "%s.%s" (car tbl) (cadr tbl))))
              cl))))

As you can see, in a schema that includes tables with spaces in their
names, those become completion objects ("Foo Bar" for instance,
sans quotes of course).

When something that then goes to make use of the completion list tries
to pass along "Foo Bar" (sans quotes) to the function that I
patched, it causes an issue.

With a little modification, my original patch could account for
differing open/close quotations as you referenced (and the patch itself
does nothing if the quotation feature is not set).

Do you think a better fix would be to quote the postgres completion list
when necessary?  (if a space in one of the table names is found)?

Because as it is, it doesn't work well with some completion modes like
helm (which just display the completion list candidates verbatim, and
expect the user to press RET on one of them to select it).

-- 
Matthew Carter (address@hidden)
http://ahungry.com



reply via email to

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