Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoting with double $-sign ($$) turns the rest of sql-code visual as text, till corresponding close $$ #7294

Closed
casparsch opened this issue Mar 18, 2024 · 11 comments
Assignees
Milestone

Comments

@casparsch
Copy link

casparsch commented Mar 18, 2024

Describe the bug
Since release 8.4 I experience following:
The text for writing a function, procedure or anonymous block is visualized as text when it comes across a "$$"-token
This textual visualization remains till the corresponding $$ at the end. This obstructs e.g. the highlighting of keywords and texts.
If there is anything in between the two $-characters (opening and closing) the keywords and texts are again highlighted
I would like to revert to the $$ ... $$ to have a similar visualization as $anything$ ... $anything$ as it was before release 8,4

To Reproduce

Steps to reproduce the behavior:

  1. Open a "Query Tool"
  2. Type:
DO $$
DECLARE
    _txt text := 'some text';
BEGIN
END;
$$;
  1. See the visualization of the code
  2. Put for example a: "x" between the adjacent $-characters. Both at the start and at the end.
  3. Look at the visual difference.

Expected behavior
I would like to have the visualization of $x$ ... $x$ when using $$ ... $$

Error message
No technical error but visual "error"

Screenshots
Screenshot from 2024-03-18 17-01-48

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):
It is on a: "rocky-linux 9" operating system.

pgAdmin Runtime Environment

Python Path: "/usr/pgadmin4/venv/bin/python3"
Runtime Config File: "/home/splendid/.config/pgadmin/runtime_config.json"
pgAdmin Config File: "/usr/pgadmin4/web/config.py"
Webapp Path: "/usr/pgadmin
(https://github.com/pgadmin-org/pgadmin4/assets/121792923/50f52290-0509-4dcd-b018-f8d2b04ccf62)
4/web/pgAdmin4.py"
pgAdmin Command: "/usr/pgadmin4/venv/bin/python3 -s /usr/pgadmin4/web/pgAdmin4.py"
Environment:

  • SHELL: /bin/bash
  • SESSION_MANAGER: local/unix:@/tmp/.ICE-unix/11696,unix/unix:/tmp/.ICE-unix/11696
  • HISTCONTROL: ignoredups
  • XDG_MENU_PREFIX: gnome-
  • GTK_IM_MODULE: ibus
  • HOSTNAME: localhost
  • HISTSIZE: 1000
  • GNOME_SHELL_SESSION_MODE: classic
  • SSH_AUTH_SOCK: /run/user/1000/keyring/ssh
  • XMODIFIERS: @im=ibus
  • DESKTOP_SESSION: gnome-classic
  • PWD: /home/splendid
  • XDG_SESSION_DESKTOP: gnome-classic
  • LOGNAME: splendid
  • XDG_SESSION_TYPE: wayland
  • MODULESHOME: /usr/share/Modules
  • MANPATH: /usr/share/man:
  • SYSTEMD_EXEC_PID: 11712
  • XAUTHORITY: /run/user/1000/.mutter-Xwaylandauth.GET0K2
  • GJS_DEBUG_TOPICS: JS ERROR;JS LOG
  • GDM_LANG: en_US.UTF-8
  • __MODULES_SHARE_MANPATH: :1
  • HOME: /home/splendid
  • USERNAME: splendid
  • LANG: en_US.UTF-8
  • XDG_CURRENT_DESKTOP: GNOME-Classic:GNOME
  • WAYLAND_DISPLAY: wayland-0
  • INVOCATION_ID: b82749762f1242048070bd2902ece73a
  • MANAGERPID: 11585
  • GJS_DEBUG_OUTPUT: stderr
  • GNOME_SETUP_DISPLAY: :1
  • XDG_SESSION_CLASS: user
  • LESSOPEN: ||/usr/bin/lesspipe.sh %s
  • USER: splendid
  • MODULES_RUN_QUARANTINE: LD_LIBRARY_PATH LD_PRELOAD
  • LOADEDMODULES:
  • DISPLAY: :0
  • SHLVL: 0
  • QT_IM_MODULE: ibus
  • XDG_RUNTIME_DIR: /run/user/1000
  • __MODULES_LMINIT: module use --append /usr/share/Modules/modulefiles:module use --append /etc/modulefiles:module use --append /usr/share/modulefiles
  • DEBUGINFOD_URLS: https://debuginfod.centos.org/
  • which_declare: declare -f
  • JOURNAL_STREAM: 8:41178
  • XDG_DATA_DIRS: /home/splendid/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/
  • PATH: /usr/pgsql-15/bin/:/home/splendid/.local/bin:/home/splendid/bin:/usr/share/Modules/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
  • MODULEPATH: /etc/scl/modulefiles:/usr/share/Modules/modulefiles:/etc/modulefiles:/usr/share/modulefiles
  • GDMSESSION: gnome-classic
  • DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus
  • MAIL: /var/spool/mail/splendid
  • GIO_LAUNCHED_DESKTOP_FILE_PID: 15863
  • GIO_LAUNCHED_DESKTOP_FILE: /usr/share/applications/pgadmin4.desktop
  • MODULES_CMD: /usr/share/Modules/libexec/modulecmd.tcl
  • GDK_BACKEND: x11
  • NO_AT_BRIDGE: 1
  • PGADMIN_INT_PORT: 36651
  • PGADMIN_INT_KEY: c030d167-616e-4308-b728-7beaf3b7f79c
  • PGADMIN_SERVER_MODE: OFF

Additional context
-- None yet

@casparsch casparsch added the Bug label Mar 18, 2024
@brsa
Copy link

brsa commented Mar 19, 2024

Plain dollar-quoting now treats the content as string constant. Dollar-quotes with nested token are transparent so that code highlighting works for function bodies et al. I consider this helpful.

@adityatoshniwal
Copy link
Contributor

@adityatoshniwal
Copy link
Contributor

@casparsch As per the docs - https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING, it is in fact a string. And so it is treated as string only.
The fact that it used to work differently in previous pgAdmin version doesn't means it was correct.

@adityatoshniwal adityatoshniwal closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2024
@casparsch
Copy link
Author

casparsch commented Mar 21, 2024

@adityatoshniwal
I just read the documentation and that is perfectly alright. It states that the tag in between the $-tokens is optional.
However I was looking at pgAdmin's visualization of that. The issue raised was not on the correctness of the implementation within postgres.
So why is $$ treated different to $tag$?

Furthermore if there is a single quote within the nested dollar-quoted-text (like in the documentation: "$SomeTag$Dianne's horse$SomeTag$") the text up-to the single quote is visual non-text and after the single quote becomes visual as text.
Screenshot from 2024-03-21 09-39-21
To me both are inconsistent visualization of text.

I would suggest following:

  • Revert to the previous (before pgAdmin4 release 8.4-1) syntax-highlighting of dollar-quoting
  • For nested dollar-quoting treat the string between the open and corresponding close nested-dollar-quote, visually as text.

@adityatoshniwal
Copy link
Contributor

@casparsch I will raise the bug to upstream CodeMirror repo. But I'm afraid it won't change the fact how $ quotes will be treated(as strings). You can follow the discussion with CodeMirror team here - https://discuss.codemirror.net/t/code-inside-do-block-treated-as-string-postgresql-dialect/8005

@adityatoshniwal
Copy link
Contributor

I'm raising this to CM team again if we have option to disable this somehow.

@adityatoshniwal
Copy link
Contributor

CM allows to disable $$ string but it was not working because of some bug in upstream. It is fixed and pgAdmin is changed accordingly.

@khushboovashi
Copy link
Contributor

Fixed with the latest code.

@khushboovashi khushboovashi moved this from In Testing to ✅ Done in Current Sprint (186) Apr 24, 2024
@khushboovashi khushboovashi added this to the 8.6 milestone Apr 24, 2024
@casparsch
Copy link
Author

Fixed with the latest code.

@khushboovashi and others as well of course.
Thanks for the development effort on this issue. I am looking forward for release 8.6. As I understand it will be released on 2nd of may 2024. Once this version is publicly available and I have it installed I will let you know if it is resolved as soon as possible.
But so far: 👍

@brsa
Copy link

brsa commented Apr 26, 2024

I am not sure how this was "fixed" exactly. Have to see in v8.6. But treating dollar-quoted strings as plain strings (while technically correct) is unhelpful. In the absolute majority of cases, dollar-quoting (with a token) is used for function bodies and other code blocks, which benefit from syntax-highlighting.

The best practice would be to treat simple strings ('string') and maybe also plain dollar-quoting without token ($$string$$) as strings, but keep up the syntax-highlighting for dollar-quoting with token $func$BEGIN ...$func$.

Related post making the same point: #7276 (comment)

@casparsch
Copy link
Author

My verification on version 8.6 gets my approval ✔️
Thank you all for resolving this issue. 🔝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants