alex-hhh / emacs-sql-indent

Syntax based indentation for SQL files inside GNU Emacs
GNU General Public License v3.0
121 stars 18 forks source link

Unexpected indentation of "on conflict" #72

Closed wedens closed 5 years ago

wedens commented 5 years ago

Indented version:

INSERT INTO tbl (col1, col2)
VALUES (1, 2)
  ON CONFLICT (col1) DO
  UPDATE SET col2 = EXCLUDED.col2

Expected (line 3 and 4 on the same level as values:

INSERT INTO tbl (col1, col2)
VALUES (1, 2)
ON CONFLICT (col1) DO
UPDATE SET col2 = EXCLUDED.col2

syntax of line 3 and 4: (((in-insert-clause "values") . 52) (statement-continuation . 1))

I use sqlind-setup-style-left style in my configuration.

alex-hhh commented 5 years ago

This works as expected, the sqlind-setup-style-left indentation style is configured to indent lines inside an insert clause by "one step" (a sqind-basic-offset). This is the in-insert-clause syntax symbol.

To make it indent the way you want, you will need to write your own indentation style -- you can copy sqlind-indentation-left-offsets-alist and replace the + with a 0 in the in-insert-clause list. You can find more information about customizing the indentation in the sql-indent.org manual

wedens commented 5 years ago

Ok. Thanks. I'll try to make a custom style.