Ability to work in streaming mode
bogdan opened this issue · comments
The binary always waits for the STDIN to be closed and than formats all supplied sql:
$ pg_format -
select * from companies;
select * from companies;
Ctrl+D
SELECT
*
FROM
companies;
SELECT
*
FROM
companies;
This restricts the ability to work in streaming mode.
Is it possible to format one SQL statement as long as it finishes (e.g. by ;
)?
cat
can be used as example as it triggers output on each line break
Hi,
If you want to format a query in interactive mode you must use the following:
echo "select * from companies;" | pg_format -
and call pg_format -
each time you want to format e new query.
I agree that this is not convenient for streaming mode. I will see if there is a simple way to allow that.
This could be handled using the Perl module Term::ReadLine
but I'm not sure it could be helpful to have such feature. What is your use case for this feature?
I am calling pg_format
executive from ruby program. It takes ~200ms to do, which is way too slow. If I can keep a running process in memory and interact with it through stdin and stdout (which what any programming language probably allows), the indent can be much faster.
Maybe use the Record Separator ASCII/Unicode symbol? It’s 0x1E
in Utf-8