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

can't handle valid set syntax

Open dotysan opened this issue 2 years ago • 8 comments

Example:

set intervalstyle = 'sql_standard';

image

AFAIK, that's perfectly valid PostgreSQL.

dotysan avatar May 19 '23 16:05 dotysan

See this for an explanation: https://github.com/Borvik/vscode-postgres/issues/160

Borvik avatar May 19 '23 16:05 Borvik

Also result window outputs this:

{"command":"SET","rowCount":null,"oid":null,"rows":[],"fields":[],"RowCtor":null,"rowAsArray":true}

Maybe it should just hide the output?

dotysan avatar May 19 '23 16:05 dotysan

Aha, I see it in the db console now. Thanks for explanation.

db-1   | 2023-05-19 16:46:27.117 UTC [462] ERROR:  syntax error at or near "set" at character 9
db-1   | 2023-05-19 16:46:27.117 UTC [462] STATEMENT:  EXPLAIN set intervalstyle = 'iso_8601';

dotysan avatar May 19 '23 16:05 dotysan

as for hiding the output... I would not propose that entirely... mainly because with 0 output you wouldn't know success/failure of the command being run

however changing the format/output for various commands (like SET, or other non-standard results) would definitely be considered

Borvik avatar May 19 '23 16:05 Borvik

Agreed. Maybe just [command] success or something similar.

dotysan avatar May 19 '23 16:05 dotysan

NEVERMIND: Just read the README. ;-)

Which brings me to my original issue, how to override the format for an interval?

It appears to be hard-coded to iso_8601, but I'd like to change it to sql_standard. But doing anything with intervalstyle seems to produce corrupt output.

dotysan avatar May 19 '23 16:05 dotysan

in order for the interval to be formatted and parsed by the extension - it needs to be returned from postgres in a consistent format

to alter the format uses a setting: image

Borvik avatar May 19 '23 16:05 Borvik

Yep, thx! Just found that. Sorry for the noise.

dotysan avatar May 19 '23 17:05 dotysan