[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/sql-indent d9442ed 03/13: Recognize FULL JOIN, UNION AL
From: |
Alex Harsanyi |
Subject: |
[elpa] externals/sql-indent d9442ed 03/13: Recognize FULL JOIN, UNION ALL and EXCEPT keywords #73 (#74) |
Date: |
Thu, 20 Jun 2019 05:25:45 -0400 (EDT) |
branch: externals/sql-indent
commit d9442ed6a9212c5c2b4788952c02f6b89ad7a32b
Author: Alex Harsányi <address@hidden>
Commit: GitHub <address@hidden>
Recognize FULL JOIN, UNION ALL and EXCEPT keywords #73 (#74)
* sql-indent.el (sqlind-select-clauses-regexp): match "UNION
ALL" and "EXCEPT" as select clauses.
(sqlind-select-join-regexp): match FULL JOIN keywords
(sqlind-lineup-joins-to-anchor): use `sqlind-select-join-regexp`
to match all join keywords.
---
sql-indent-test.el | 3 +++
sql-indent.el | 6 +++---
test-data/pr73-syn.eld | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
test-data/pr73.sql | 34 +++++++++++++++++++++++++++++
4 files changed, 98 insertions(+), 3 deletions(-)
diff --git a/sql-indent-test.el b/sql-indent-test.el
index ef5d050..8912daf 100644
--- a/sql-indent-test.el
+++ b/sql-indent-test.el
@@ -384,4 +384,7 @@ information read from DATA-FILE (as generated by
(ert-deftest sqlind-ert-pr70 ()
(sqlind-ert-check-file-syntax "test-data/pr70.sql" "test-data/pr70-syn.eld"))
+(ert-deftest sqlind-ert-pr73 ()
+ (sqlind-ert-check-file-syntax "test-data/pr73.sql" "test-data/pr73-syn.eld"))
+
;;; sql-indent-test.el ends here
diff --git a/sql-indent.el b/sql-indent.el
index 4e0fd34..b2c03e3 100644
--- a/sql-indent.el
+++ b/sql-indent.el
@@ -948,7 +948,7 @@ reverse order (a stack) and is used to skip over nested
blocks."
(defconst sqlind-select-clauses-regexp
(concat
"\\_<\\("
- "\\(union\\|intersect\\|minus\\)?[ \t\r\n\f]*select\\|"
+ "\\(\\(union\\(\\s-+all\\)?\\)\\|intersect\\|minus\\|except\\)?[
\t\r\n\f]*select\\|"
"\\(bulk[ \t\r\n\f]+collect[ \t\r\n\f]+\\)?into\\|"
"from\\|"
"where\\|"
@@ -961,7 +961,7 @@ reverse order (a stack) and is used to skip over nested
blocks."
"\\)\\_>"))
(defconst sqlind-select-join-regexp
- (regexp-opt '("inner" "left" "right" "natural" "cross") 'symbols))
+ (regexp-opt '("inner" "left" "right" "natural" "cross" "full") 'symbols))
(defconst sqlind-join-condition-regexp
(regexp-opt '("on" "using" "and" "or") 'symbols))
@@ -2180,7 +2180,7 @@ it will indent lines starting with JOIN keywords to line
up with
the FROM keyword."
(save-excursion
(back-to-indentation)
- (if (looking-at "\\b\\(\\(inner\\|outer\\|cross\\)\\s-+\\)?join\\b")
+ (if (looking-at (concat "\\b\\(" sqlind-select-join-regexp
"\\s-+\\)?join\\b"))
(sqlind-lineup-to-anchor syntax base-indentation)
base-indentation)))
diff --git a/test-data/pr73-syn.eld b/test-data/pr73-syn.eld
new file mode 100644
index 0000000..330bff7
--- /dev/null
+++ b/test-data/pr73-syn.eld
@@ -0,0 +1,58 @@
+(((toplevel . 1))
+ ((select-clause . 1)
+ (statement-continuation . 1))
+ ((select-table-continuation . 12)
+ (statement-continuation . 1))
+ ((select-join-condition . 30)
+ (statement-continuation . 1))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ ((select-clause . 76)
+ (statement-continuation . 76))
+ ((select-clause . 76)
+ (statement-continuation . 76))
+ ((select-clause . 76)
+ (statement-continuation . 76))
+ ((select-clause . 76)
+ (statement-continuation . 76))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ ((select-clause . 127)
+ (statement-continuation . 127))
+ ((select-clause . 127)
+ (statement-continuation . 127))
+ ((select-clause . 127)
+ (statement-continuation . 127))
+ ((select-clause . 127)
+ (statement-continuation . 127))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ ((select-clause . 178)
+ (statement-continuation . 178))
+ ((select-clause . 178)
+ (statement-continuation . 178))
+ ((select-clause . 178)
+ (statement-continuation . 178))
+ ((select-clause . 178)
+ (statement-continuation . 178))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ ((select-clause . 233)
+ (statement-continuation . 233))
+ ((select-clause . 233)
+ (statement-continuation . 233))
+ ((select-clause . 233)
+ (statement-continuation . 233))
+ ((select-clause . 233)
+ (statement-continuation . 233))
+ ((toplevel . 1))
+ ((toplevel . 1))
+ ((select-clause . 284)
+ (statement-continuation . 284))
+ ((select-clause . 284)
+ (statement-continuation . 284))
+ ((select-clause . 284)
+ (statement-continuation . 284))
+ ((select-clause . 284)
+ (statement-continuation . 284))
+ ((toplevel . 1)))
\ No newline at end of file
diff --git a/test-data/pr73.sql b/test-data/pr73.sql
new file mode 100644
index 0000000..aa4cda7
--- /dev/null
+++ b/test-data/pr73.sql
@@ -0,0 +1,34 @@
+select *
+ from foo
+ full join bar
+ on foo.k = bar.k;
+
+select id
+ from foo
+except
+select id
+ from bar;
+
+select id
+ from foo
+ union
+select id
+ from bar;
+
+select id
+ from foo
+ union all
+select id
+ from bar;
+
+select id
+ from foo
+ minus
+select id
+ from bar;
+
+select id
+ from foo
+intersect
+select id
+ from bar;
- [elpa] externals/sql-indent updated (87a6b4a -> 47e9ccb), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 9d5f978 05/13: Fix regexp bug in `sqlind-good-if-candidate` (fixes #76), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 31c29ed 12/13: Recognize more types of begin transaction statements (fixes #84), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 2ca9610 09/13: don't be confused by drop function or procedure statements #80, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent f897c11 08/13: Apply advices of `checkdoc' (#77), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent dccd194 02/13: Recognize `select-join-condition` syntax inside nested statements #70 (#71), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent e7e7e85 11/13: Don't recognize select keywords in comments, fixes #83, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 47e9ccb 13/13: Recognize left and right outer join statements #85, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent e511ced 01/13: `sqlind-search-backward` finds things at the same nesting level (#68) (#69), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent d9442ed 03/13: Recognize FULL JOIN, UNION ALL and EXCEPT keywords #73 (#74),
Alex Harsanyi <=
- [elpa] externals/sql-indent 1974564 10/13: recognize elseif in addition to elif #81, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent 9559ebe 07/13: Fix `sqlind-comment-end' regexp. (#79), Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent ba2a690 06/13: also fix sqlind-end-statement-regexp, Alex Harsanyi, 2019/06/20
- [elpa] externals/sql-indent a6da8bd 04/13: Recognize more create keywords (#75), Alex Harsanyi, 2019/06/20