Skip to content

Preserve comment lines and leading commas in SQL formatting #899

@satt-hri

Description

@satt-hri

Hi,

I noticed that when formatting SQL with inline comments and leading commas, the formatter moves comments to the end of the previous line and changes the comma placement.

Example SQL I want to keep:

INSERT INTO sco_progress_log(
rec_datetime
,log_type

/* __CF_IF5__ */
,caller_sco_id
/* __CF_IF6__ */

,complete_date
)
SELECT
__CF_PARAM0__
,'rireki'
,NULL

/* __CF_IF7__ */
,__CF_PARAM1__
/* __CF_IF8__ */

FROM sco_progress ins_data
WHERE user_id = __CF_PARAM2__
AND course_id = __CF_PARAM3__
AND sco_id = __CF_PARAM4__

Formatted result:

INSERT INTO
	sco_progress_log (
		rec_datetime,
		log_type
		/* __CF_IF5__ */
,
		caller_sco_id
		/* __CF_IF6__ */
,
		complete_date
	)
SELECT
	__CF_PARAM0__,
	'rireki',
	NULL
	/* __CF_IF7__ */
,
	__CF_PARAM1__
	/* __CF_IF8__ */

FROM
	sco_progress ins_data
WHERE
	user_id = __CF_PARAM2__
	AND course_id = __CF_PARAM3__
	AND sco_id = __CF_PARAM4__

Issues:

  1. Comments (/* __CF_IFx__ */) are moved to the previous line instead of staying on their own line.
  2. Leading commas are reformatted.

Is there a way to preserve comment lines and leading commas? If not, could this be considered as a feature request?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions