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

Multi-line SQL generated by pgAdmin that is pasted into "Filter Rows..." results in a syntax error #8254

Open
usernamesareaholdoverfromthe90s opened this issue Dec 11, 2024 · 0 comments

Comments

@usernamesareaholdoverfromthe90s

Describe the bug

Generated SQL copied from one pgAdmin window into a "Filter Rows..." window of another results in broken SQL because the CR/LF is not interpreted as white space

To Reproduce

Assume you have a table called Person, with PK "person_id_pk", and a table called Student with FK "person_id_fk".

Steps to reproduce the behavior:

  1. Right-click on the Person table, and select "View/Edit Data" | "Filtered Rows..."
  2. Type in some text, e.g.,

last_name = 'Doe' and (first_name = 'John' or first_name = 'Jane')

  1. Click OK to run the query
  2. Note that the SQL listed in the result looks like
SELECT * FROM public.person
WHERE last_name = 'Doe' and (first_name = 'John' or first_name = 'Jane')
  1. Select and copy the generated SQL
  2. Right-click on the Student table, and select "View/Edit Data" | "Filtered Rows..." (with the intent to use the previous query to select rows)
  3. Type in "person id in ()", and then paste in the copied SQL within the parentheses, and change the "*" to be "person_id_pk", so that you end up with
person_id_fk in (SELECT person_id_pk FROM public.person
WHERE last_name = 'Doe' and (first_name = 'John' or first_name = 'Jane'))
  1. Click OK to run the query
    --> BUG#1: you get a syntax error in the result pane
ERROR:  syntax error at or near "="
LINE 2: ...ELECT person_id_pk FROM public.personWHERE last_name = 'Doe' and...
                                                             ^ 

SQL state: 42601
Character: 100

I.e, the CR/LF at the end of line 1 of the generated/copied/pasted SQL is being stripped out, but not replaced with a space, so the two joined lines are resulting in illegal syntax.

--> BUG#2: you can't edit the query to correct the mistake. I.e., clicking on the "Sort/Filter" icon doesn't do anything (and, hovering over it shows the default (arrow) cursor without tooltip, rather than the pointer (finger) cursor saying "Sort/Filter". So all you can do is go back to step 6, and start again.

Note, the work around in step 7 is to put the cursor at the end of line 1 and manually add a space character after "public.person"

Expected behavior

I expect that when someone pastes in multi-line SQL, and if those lines really do need to be joined, then you'd ensure that that a space character is used (e.g., use .join( " " ), rather than .join( "" )... depending on the language you're using) so that it doesn't result in a syntax error. Or perhaps the CR/LF shouldn't be stripped out at all?

And, I would expect that if the "View/Edit Data" | "Filtered Rows..." contains a syntax error, I should be able to click on the "Sort/Filter" icon to correct my mistake.

Error message

See step 8, above

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version: 8.13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants