From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Matthew Carter Newsgroups: gmane.emacs.devel Subject: Patch for sql.el (quote table names in sql-list-table) Date: Wed, 27 Jan 2016 22:37:27 -0500 Organization: Ahungry (http://ahungry.com) Message-ID: <87egd274so.fsf@ahungry.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1453952335 32654 80.91.229.3 (28 Jan 2016 03:38:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 Jan 2016 03:38:55 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 28 04:38:46 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aOdPq-0003Vd-23 for ged-emacs-devel@m.gmane.org; Thu, 28 Jan 2016 04:38:38 +0100 Original-Received: from localhost ([::1]:53829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOdPp-00004s-HS for ged-emacs-devel@m.gmane.org; Wed, 27 Jan 2016 22:38:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOdPV-00086x-KX for emacs-devel@gnu.org; Wed, 27 Jan 2016 22:38:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOdOv-0007l5-4Y for emacs-devel@gnu.org; Wed, 27 Jan 2016 22:38:17 -0500 Original-Received: from li130-200.members.linode.com ([69.164.215.200]:49145 helo=mail.ahungry.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOdOu-0007g5-U6 for emacs-devel@gnu.org; Wed, 27 Jan 2016 22:37:40 -0500 Original-Received: from Prometheus (99-40-9-245.lightspeed.livnmi.sbcglobal.net [99.40.9.245]) by mail.ahungry.com (Postfix) with ESMTPSA id 64A0C118032 for ; Wed, 27 Jan 2016 22:37:28 -0500 (EST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 69.164.215.200 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:198932 Archived-At: --=-=-= Content-Type: text/plain Hello all, The following patch quotes a table name when the :quotation value is set for product features in sql.el mode, to prevent unanticipated SQL errors in cases where the table name has something like a space (or other reserved character) in it, as it may not be immediately apparent that the user should have entered their quotation characters in the sql-list-table prompt during sql-mode. The previous behavior (no quoting) can be enabled in the user's config file by adding something such as: (sql-set-product-feature 'postgres :quotation nil) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=sql-list-tables-with-quotation.patch Content-Description: Quote the table name diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 65e94ba..88e1417 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -430,6 +430,7 @@ file. Since that is a plaintext file, this could be dangerous." :prompt-regexp "^mysql> " :prompt-length 6 :prompt-cont-regexp "^ -> " + :quotation "`" :syntax-alist ((?# . "< b")) :input-filter sql-remove-tabs-filter) @@ -465,6 +466,7 @@ file. Since that is a plaintext file, this could be dangerous." :prompt-regexp "^\\w*=[#>] " :prompt-length 5 :prompt-cont-regexp "^\\w*[-(][#>] " + :quotation "\"" :input-filter sql-remove-tabs-filter :terminator ("\\(^\\s-*\\\\g$\\|;\\)" . "\\g")) @@ -3768,6 +3770,9 @@ ENHANCED, displays additional details about each column." (user-error "No SQL interactive buffer found")) (unless name (user-error "No table name specified")) + (when (sql-get-product-feature sql-product :quotation) + (let ((quote (sql-get-product-feature sql-product :quotation))) + (setf name (format "%s%s%s" quote name quote)))) (sql-execute-feature sqlbuf (format "*List %s*" name) :list-table enhanced name))) --=-=-= Content-Type: text/plain -- Matthew Carter (m@ahungry.com) http://ahungry.com --=-=-=--