question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format of pasted query

See original GitHub issue

When I paste a query with line breaks into pgcli, the lines are joined without a space.

for example:

select col
from table

becomes

select colfrom table

which is a syntax error

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
amjithcommented, Jul 7, 2016

@iamrahulroy That’s debatable. Some of the default behaviors in psql are just terrible, so I’m ok deviating from what is considered default in psql.

But this one is a subjective call and I’m not sure there is a good way to objectively say one is better than the other. I’ve chosen what I think is the most common use case, which is people type in queries in a single line and multi-line queries are rare. So I’ve optimized based on that use case. But if a user prefers to emulate psql there is a config option that allows them to do that.

The philosophy behind pgcli is “Sane defaults out of the box”.

1reaction
amjithcommented, Apr 24, 2015

Actually in order to paste multi-line strings like the one in the example, you have to enable the multi-line mode (F3 key).

If you notice the syntax error says

misago> select colfrom table
column "col" does not exist
LINE 1: select col

Even though it printed it as select colfrom table what it actually did was it pasted select col and the newline after that was treated as <enter> and it sent the partial query to the server and then pasted the rest of the query into the buffer.

But if you enable multiline-mode and then paste the same snippet, it will be pasted correctly and then you can end it with a semicolon and press enter to execute the query.

Try it out and let me know if it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pasting SQL formatted code into Excel cell
The solution I have is to first get in edit mode of the cell (F2 or double click) and paste the first line...
Read more >
How to format a query letter
This is how you format an e-mailed query letter. ... to have stripped any lingering formatting (pasting with Alt-Shift-Command-V can help).
Read more >
How to keep the SQL formatting in copy and paste?
How to keep the SQL formatting in copy and paste? · go to Insert tab, Text section, click object button (it's on the...
Read more >
Formatting when copying SQL data and pasting in Excel
In the data tab click on Text to Columns, in the pop-up window select Delimited, then uncheck all of the boxes in Step...
Read more >
Copying formatted text out of a grid column.
The last thing you want to get when you copy and paste the output is ... an already existing window then either go...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found