Code inside DO $$ block treated as string - PostgreSQL dialect

Hi,

The code inside DO $$ block is treated as string. Because of which, syntax highlighting doesn’t work. This used to work in CM5. Screenshot from CM5:
image

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQgeyBzcWwsIFBvc3RncmVTUUwgfSBmcm9tICdAY29kZW1pcnJvci9sYW5nLXNxbCc7CgpuZXcgRWRpdG9yVmlldyh7CiAgZG9jOiBgRE8gJCRcbkRFQ0xBUkVcbiAgICBfdHh0IHRleHQgOj0gJ3NvbWUgdGV4dCc7XG5CRUdJTlxuRU5EO1xuJCQ7YCwKICBleHRlbnNpb25zOiBbYmFzaWNTZXR1cCwKICAgICAgICAgICAgICAgIHNxbCh7CiAgICBkaWFsZWN0OiBQb3N0Z3JlU1FMLAogIH0pLAogICAgICAgICAgICAgIF0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5LAp9KQo=

Screenshot from CM6:

That’s because those are string tokens. The fact that it doesn’t do the same for $BODY$ was a bug (addressed here).

1 Like

Oh I see. Thank you for the response.

Hi @marijn,

I revisited this and want to know why $x$ tagged(with name in between dollars) are not treated as strings?
Secondly, if there is a single quote in between then highlighting looks incorrect.

Probably because the new patch hadn’t been published yet. Try again with @codemirror/lang-sql 6.6.2

1 Like

Works with 6.6.2. Thanks.

Hi @marijn,

I understand the code is implemented based on PostgreSQL docs. But it is not helpful in many cases for example a PostgreSQL function. A lot of pgAdmin users are raising this issue of syntax highlighting.
I’m wondering if there is a way to disable it?

Hi @marijn,
Will you accept a PR to make this optional?
People are not liking that a complete code is treated as string with no syntax highlighting.

You can already turn that off without a PR (see this example). But there was a bug that broke that, so you’ll have to upgrade to @codemirror/lang-sql 6.6.3.

Awesome! Thank you so much.