darold / pgFormatter

A PostgreSQL SQL syntax beautifier that can work as a console program or as a CGI. On-line demo site at http://sqlformat.darold.net/
PostgreSQL License
1.66k stars 100 forks source link

now seems you cannot limit number of chars per line? #313

Closed jianhe-fun closed 1 year ago

jianhe-fun commented 1 year ago

can you set the limits then the remaining line expand to the next line?

darold commented 1 year ago

Please post an example, I'm not sure to understand what you mean.

jianhe-fun commented 1 year ago
CREATE OR REPLACE FUNCTION create_post (uid_query text, post_text_query text DEFAULT '', text_url_query text DEFAULT '', photo_url_query text DEFAULT '', video_url_query text DEFAULT '', audio_url_query text DEFAULT '', location_query text DEFAULT '', tags_array_query text[] DEFAULT '{general}', photo_query bool DEFAULT FALSE, out post_insert_id int)
    RETURNS integer
    LANGUAGE plpgsql
    AS $func$

as you can see, first line is far too long.

jianhe-fun commented 1 year ago

set the line textwidth limit.

darold commented 1 year ago

If you use the --wrap-limit it works fine:

 perl pg_format a.sql -w 80
CREATE OR REPLACE FUNCTION create_post (uid_query text, post_text_query text
    DEFAULT '', text_url_query text DEFAULT '', photo_url_query text DEFAULT '', video_url_query text DEFAULT '',
    audio_url_query text DEFAULT '', location_query text DEFAULT '', tags_array_query text[] DEFAULT
    '{general}', photo_query bool DEFAULT FALSE, out post_insert_id int)
    RETURNS integer
    LANGUAGE plpgsql
    AS $func$

but as you don't provide your pg_format command line I guess that this is not what you are using.