vscode-postgres icon indicating copy to clipboard operation
vscode-postgres copied to clipboard

Feature Request: tell which line is causing the error

Open igorcafe opened this issue 2 years ago • 11 comments

In my case, where I have a bunch of "VALUES": image

I can't really know which one is this error talking about: image

igorcafe avatar Sep 29 '21 13:09 igorcafe

Ok, I just realized what was the mistake. But anyways the feature request still valid.

igorcafe avatar Sep 29 '21 13:09 igorcafe

So all errors (whether the squiggles or during actual query running) come from the PostgreSQL server itself. If PostgreSQL does not return positional data it can't be shown.

Borvik avatar Oct 05 '21 09:10 Borvik

So all errors (whether the squiggles or during actual query running) come from the PostgreSQL server itself. If PostgreSQL does not return positional data it can't be shown.

Postgres returns additional info for each error, exact querry part, position and other stuff, however extension shows only message part of error object, if you could change to show all object instead, that would be perfect.

Edzukins avatar Aug 31 '22 07:08 Edzukins

Not always... like I said, if it returns positional data, I attempt to use it.

Interesting that I tried replicating the type of the errors in the queries (multiple statements with no semi-colon to separate them, multiple VALUES keywords in a single statement, and missing commas between values) - and it did seem to highlight (granted it can only grab the first error).

image

What version of postgres are you connected to?

Borvik avatar Aug 31 '22 10:08 Borvik

if we talk about highlighting it is not working for me, because I probably not doing something correctly. When I open new query, everything is mostly fine, some simple errors it can show even before I run it: image But once I save it (as .psql) then it does not work anymore image Probobly problem is in some configuarion in my case. But anyway, if whole error object would be displayed, it would help in in some situations (not in this one, as there is only one '<' but in others), or at least to make message something like pgadmin: image

My version is 13.6

Edzukins avatar Aug 31 '22 11:08 Edzukins

interesting... do you have any error logs for the postgres language service?

Borvik avatar Aug 31 '22 11:08 Borvik

Any idea where to find them? Windows 10

Edzukins avatar Aug 31 '22 11:08 Edzukins

Output tab from vscode image

Borvik avatar Aug 31 '22 11:08 Borvik

c:....vscode\extensions\ckolkman.vscode-postgres-1.4.0\out\language\server.js:341 source: dbConnOptions.host ^

TypeError: Cannot read properties of null (reading 'host') at c:....vscode\extensions\ckolkman.vscode-postgres-1.4.0\out\language\server.js:341:47 at Generator.throw () at rejected (c:....vscode\extensions\ckolkman.vscode-postgres-1.4.0\out\language\server.js:6:65) at processTicksAndRejections (node:internal/process/task_queues:96:5) [Info - 2:03:01 PM] Connection to server got closed. Server will restart. expected password response, got message type 88

Edzukins avatar Aug 31 '22 11:08 Edzukins

interesting.... based on that error it looks like the language server is losing connection in the middle of validating the statement.

Might be tricky to replicate, but maybe it has something to do with the act of saving the query clearing the connection.

Borvik avatar Aug 31 '22 12:08 Borvik

I checked again, and problem why error (position) was not showing was because I just copied this query at end of other query without "; " Once I separated them, it shows where error is (before I run it). I guess this is just limitation that everyone need to understand when writing multiple separate queries in one file, and running only one of it by selection -it might not show error, if it is not separated from last query. In pg_admin it will show error position and extra info no matter what is before that query, so this is not intuitive thing to think about when running querries.

Edzukins avatar Aug 31 '22 17:08 Edzukins