Skip to content

SQL query editor completion: Special characters in column names not supported #16314

Open

Description

@markus-ksg

Describe the bug

The Ctrl+Space code completion in the SQL query editor doesn't support special characters in column names very well.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://demo.phpmyadmin.net/master-config/index.php?route=/table/sql&db=burger_code&table=categories&server=1
  2. Add columns ITM-main# and #main (names contain special characters):
ALTER TABLE `categories` ADD `ITM-main#` INT NOT NULL AFTER `name`; 
ALTER TABLE `categories` ADD `#main` INT NOT NULL AFTER `name`; 
  1. Try to use the columns in SQL query completion (Ctrl+Space). Examples after inital query text ( | is the prefix/completion position; press Ctrl+Space, choose ITM-main# or #main from the popup):
SELECT * FROM `categories` WHERE |
prefix result expected
(none) ITM-main# `ITM-main#`
IT ITM-main# `ITM-main#`
ITM- ITM-ITM-main# `ITM-main#` (or ITM-`ITM-main#` if you consider the - a difference operator)
` `ITM-main#` `ITM-main#` (good)
`ITM `ITM-main#` `ITM-main#` (good)
`ITM- `ITM-ITM-main# `ITM-main#`
`ITM-ma no useful proposals `ITM-main#`
# ##main `#main`
#ma #ma#main `#main`
` `#main` `#main` (good)
`# `##main `#main`
`#ma `#ma#main `#main`

Expected behavior

Completion of special column names should work like for columns with regular names. After choosing something from the popup, the column name should be completed and enclosed in ` ` if necessary.

Server configuration

  • phpMyAdmin version: 5.0.2, 5.1.0-dev, and older versions

Activity

  1. changed the title [-]SQL query editor: Special characters in column names not supported[/-] [+]SQL query editor completion: Special characters in column names not supported[/+] on Aug 24, 2020
  2. markus-ksg commented on Sep 8, 2020

    @markus-ksg
    Author

    To reproduce if the example database burger_code doesn't exist, just create the database and then create table categories with column name.

  3. williamdes commented on Sep 8, 2020

    @williamdes
    Member

    Thank you for reporting this issue, I hope someone will have a look into it :)

  4. added
    Bug
    Enhancement
    on Oct 14, 2020
  5. shucon commented on Oct 19, 2020

    @shucon
    Contributor

    Starting to work on this.

  6. williamdes commented on Feb 9, 2021

    @williamdes
    Member

    Hi @markus-ksg

    Would you agree to test the latest version in development (phpMyAdmin 5.1+snapshot) ?
    I think this is fixed now

  7. added this to the 5.1.0 milestone on Feb 9, 2021
  8. markus-ksg commented on Feb 10, 2021

    @markus-ksg
    Author

    I'd love to test it, but I couldn't find a Docker image that includes the latest 5.1 code.

    I'm currently using the phpmyadmin/phpmyadmin:latest image, which contains 5.0.4. I tried to replace /var/www/html in the running docker container with the contents of https://files.phpmyadmin.net/snapshots/phpMyAdmin-5.1+snapshot-english.tar.gz . After chown -R --reference=html.bak html ; chmod --reference=html.bak html, I did get the login page, but after entering the credentials, I got redirected to /index.php?route=/ with error message "mysqli::real_connect(): (HY000/2002): No such file or directory".
    Do you have any hints on how I could test this locally?

    https://demo.phpmyadmin.net/QA_5_1 shows some general error messages. After ignoring them, the bug still reproduces.
    https://demo.phpmyadmin.net/master/ (5.2) also still exhibits the described bad behavior.

    I'm afraid codemirror/codemirror5#6331 was not enough to fix this.

  9. ibennetch commented on Feb 10, 2021

    @ibennetch
    Member

    I'd love to test it, but I couldn't find a Docker image that includes the latest 5.1 code.

    That's correct, we don't publish Docker images for prerelease or release candidate versions.

    chown -R --reference=html.bak html

    You taught me a new argument to use with chown, nice!

    Do you have any hints on how I could test this locally?

    Probably you need to change one line, in libraries/vendor_config.php find the line define('CONFIG_DIR', ROOT_PATH); and change it to define('CONFIG_DIR', '/etc/phpmyadmin/'); (this is how the Docker image knows where to find the configuration files).

    https://demo.phpmyadmin.net/QA_5_1 shows some general error messages.

    This should be cleared up now.

    After ignoring them, the bug still reproduces.
    https://demo.phpmyadmin.net/master/ (5.2) also still exhibits the described bad behavior.

    That's unfortunate, thank you for the testing and response!

  10. markus-ksg commented on Feb 10, 2021

    @markus-ksg
    Author

    Do you have any hints on how I could test this locally?

    Probably you need to change one line, in libraries/vendor_config.php find the line define('CONFIG_DIR', ROOT_PATH); and change it to define('CONFIG_DIR', '/etc/phpmyadmin/'); (this is how the Docker image knows where to find the configuration files).

    Thanks, that was it! Great that I can now test pre-release versions in my Docker setup. 5.1 looks good so far, but as expected, this bug also shows up locally.
    I guess it's a CodeMirror issue in the completion implementation, since there are cases where useful column proposals are computed, but insertion fails to find the correct starting position.

  11. modified the milestones: 5.1.0, 5.1.1 on Feb 24, 2021
  12. modified the milestones: 5.1.1, 5.1.2 on Apr 22, 2021
  13. modified the milestones: 5.1.2, 5.1.3 on Jul 27, 2021
  14. modified the milestones: 5.1.3, 5.1.4 on Feb 11, 2022
  15. modified the milestones: 5.1.4, 5.2.1 on May 11, 2022
  16. added
    affects/5.2
    on Oct 25, 2022
  17. removed this from the 5.2.1 milestone on Oct 25, 2022
  18. ben-wckdrzr commented on Jun 21, 2023

    @ben-wckdrzr

    I found this page while looking for a solution to the same issue directly in CodeMirror - this is an issue in that package as mentioned, but doesn't seem to have been raised there.

    I asked a question about this on the CodeMirror discussion (https://discuss.codemirror.net/t/quoting-table-names-when-using-schemacompletionsource/6721), and a fix was implemented in @codemirror/lang-sql v6.5.1

    Not all of the test cases above pass, but most do; and enough for my needs

    Just posting here to try and keep the internet tidy :D

  19. williamdes commented on Jul 13, 2023

    @williamdes
    Member

    Just posting here to try and keep the internet tidy :D

    Thanks

    I think this is related to #18521

  20. added
    affects/6.0
    confirmed/5.2
    confirmed/6.0
    on Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugEnhancementaffects/5.2affects/6.0confirmed/5.2confirmed/6.0

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions