Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider "column" keyword in "if exists" checks (#109) #110

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sql-indent-test.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; sql-indent-test.el --- Automated tests for sql-indent.el. -*- lexical-binding: t -*-

;; Copyright (C) 2017 Free Software Foundation, Inc
;; Copyright (C) 2017, 2024 Free Software Foundation, Inc

;; Author: Alex Harsanyi (AlexHarsanyi@gmail.com)
;; Created: 23 May 2017
Expand Down Expand Up @@ -513,4 +513,9 @@ information read from DATA-FILE (as generated by
"test-data/pr107.sql"
"test-data/pr107-syn.eld"))

(ert-deftest sqlind-ert-pr109 ()
(sqlind-ert-check-file-syntax
"test-data/pr109.sql"
"test-data/pr109-syn.eld"))

;;; sql-indent-test.el ends here
4 changes: 2 additions & 2 deletions sql-indent.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; sql-indent.el --- Support for indenting code in SQL files. -*- lexical-binding: t -*-

;; Copyright (C) 2015, 2017-2018 Free Software Foundation, Inc
;; Copyright (C) 2015, 2017-2018, 2024 Free Software Foundation, Inc

;; Author: Alex Harsanyi <AlexHarsanyi@gmail.com>
;; Created: 27 Sep 2006
Expand Down Expand Up @@ -496,7 +496,7 @@ We try to avoid false positives, like \"end if\" or the various
(forward-word -1)
;; we don't want to match an "end if", and things like "drop index if
;; exists..." and "create index if not exist..."
(not (looking-at "end\\|schema\\|table\\|view\\|index\\|constraint\\|type\\|trigger\\|procedure\\|function\\|routine\\|package\\|body\\|extension")))))
(not (looking-at "end\\|schema\\|table\\|column\\|view\\|index\\|constraint\\|type\\|trigger\\|procedure\\|function\\|routine\\|package\\|body\\|extension")))))

(defun sqlind-maybe-if-statement ()
"If (point) is on an IF statement, report its syntax."
Expand Down
5 changes: 5 additions & 0 deletions test-data/pr109-syn.eld
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(((toplevel . 1))
((toplevel . 1))
((comment-start . 1)
(toplevel . 1))
((toplevel . 1)))
3 changes: 3 additions & 0 deletions test-data/pr109.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alter table sometable drop column if exists col;

-- this line should not be indented