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

Empty space after host name in SQL server, cause inconsistent error #57358

Closed
2 tasks
Ertmann opened this issue May 7, 2024 · 3 comments · Fixed by #57518
Closed
2 tasks

Empty space after host name in SQL server, cause inconsistent error #57358

Ertmann opened this issue May 7, 2024 · 3 comments · Fixed by #57518
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@Ertmann
Copy link

Ertmann commented May 7, 2024

What is the bug or the crash?

This is a sneaky mistake that can prevent novice users from using QGIS with MS SQL server, simply by them doing a copy-paste of the host name. Because an empty space can sneak in undeteced, like so; "MyDomainsServer ".
The inconsistency comes when editing the connetion; the buttons "Test connection" and "List databases" works just fine, and you can see the tables in the database. But when you're done editing and go back to press connect. You get this error:
image

Steps to reproduce the issue

  1. Add an empty space after the hosname of a MS SQL server connection you know already works.
  2. (Optional) Edit the connetion; to see that the buttons "Test connection" and "List databases" works just fine.
  3. Press the connect button.
    image

Versions

4.10.3-A Coruña
3.28.8-Firenze

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@Ertmann Ertmann added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 7, 2024
@rouault
Copy link
Contributor

rouault commented May 7, 2024

https://stackoverflow.com/a/3523068/23076275 confirms a white space in a hostname is invalid

@Ertmann
Copy link
Author

Ertmann commented May 14, 2024

yeah, so instead of telling the user this, the inconsistency can help lead them astray.

@elpaso elpaso self-assigned this May 22, 2024
@elpaso
Copy link
Contributor

elpaso commented May 22, 2024

Actually, the host is trimmed (trailing/leading spaces removed): https://github.com/qgis/QGIS/blob/master/src/providers/mssql/qgsmssqlnewconnection.cpp#L306 but not when it's written: https://github.com/qgis/QGIS/blob/master/src/providers/mssql/qgsmssqlnewconnection.cpp#L160

I'll fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants