SQLPro icon indicating copy to clipboard operation
SQLPro copied to clipboard

Feature Request: SQL Editor - More configurable formatter styles

Open chrischain opened this issue 3 years ago • 4 comments

While I'm grateful that there is a formatter available in SQLPro Studio, I'm not a fan of the way it formats queries. I prefer the "river" method described by Joe Celko in his SQL Programming Style book.

I would like to have more options to configure the formatter's styling, most importantly, line breaking. Better yet, the ability to use something like The Poor Man's T-SQL Formatter (https://poorsql.com/) would be ideal.

chrischain avatar Mar 31 '21 19:03 chrischain

It does not look like I could distribute the poorsql within SQLPro as poorsql requires GPL/AGPL licensing. What I have thought about doing in the past is letting the user specify their own library for formatting via preferences. I'll take a deeper look into this for an upcoming build.

hankinsoft avatar Apr 01 '21 12:04 hankinsoft

Ah. Understandable. I would be happy if SQLPro just had some of the configurability of the PoorSQL library, but being able to use the library by specifying it in preferences would be fantastic.

Thanks!

chrischain avatar Apr 01 '21 15:04 chrischain

Hi - you mentioned looking for line breaking configuration. Could you give an example of what exactly you mean by this? I took a look at https://poorsql.com/ but I don't see anything specific to line breaks?

hankinsoft avatar Jul 15 '21 11:07 hankinsoft

Right now, if I were to type a simple query like this: SELECT id,item_name,item_type FROM dbo.table as t1 WHERE item_type = 'software'

it would be formatted like this:

SELECT
	ID,
	item_name,
	item_type
FROM
	dbo.table AS t1
WHERE
	item_type = 'software'

I would prefer if I had the option to set the line breaking to before the keywords so that it looked more like this:

SELECT	ID,
	item_name,
	item_type
FROM	dbo.table AS t1
WHERE	item_type = 'software'

Ultimately, it would be ideal if I could use river formatting, so it would look like this:

SELECT	ID,
	item_name,
	item_type
  FROM	dbo.table AS t1
 WHERE	item_type = 'software'

To take it a step further, a query with a join would look like this (JOINs go "over the river"):

SELECT	ID,
	item_name,
	item_type
  FROM	dbo.table AS t1
	JOIN dbo.table2 AS t2
	  ON t1.t2_id = t2.id
 WHERE	item_type = 'filter'

chrischain avatar Jul 16 '21 14:07 chrischain