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

AnyUrl percent encoding (#3061) introduced v1.10.0 breaks database connection string #4468

Closed
3 tasks done
doc0815 opened this issue Sep 2, 2022 · 4 comments · Fixed by #4470
Closed
3 tasks done

Comments

@doc0815
Copy link

doc0815 commented Sep 2, 2022

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

This bug-fix #3061 introduced percent encoding for the query attribute of AnyUrl. It lists a set of characters that get percent encoded and refers to the url-spec.

According to the url-spec, the + character is in the group of safe characters and should not be encoded (page 16 in the doc).

As a consequence of the introduced characters encoding, my database connection string to a MS SQL Server DB got unusable:

import pydantic


url = pydantic.AnyUrl.build(
    scheme="mssql+pyodbc",
    user="user",
    password="password",
    host="127.0.0.1",
    port="1433",
    path="/database",
    query="driver=ODBC+Driver+17+for+SQL+Server",
)
print(pydantic.VERSION)
print(url)


# 1.9.1
# mssql+pyodbc://user:password@127.0.0.1:1433/database?driver=ODBC+Driver+17+for+SQL+Server

# 1.10.1
# mssql+pyodbc://user:password@127.0.0.1:1433/database?driver=ODBC%2BDriver%2B17%2Bfor%2BSQL%2BServer

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

pydantic version: 1.9.1
pydantic compiled: True
install path: C:\Users\xxx\PycharmProjects\xxx\venv\Lib\site-packages\pydantic
python version: 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
platform: Windows-10-10.0.19044-SP0
optional deps. installed: ['typing-extensions']

It would be cool to have a MSSQLServerDsn similar to Postgres, Redis, or MongoDB instead of the general AnyUrl (https://pydantic-docs.helpmanual.io/usage/types/#urls).

@hramezani
Copy link
Member

maybe related to #4458

@samuelcolvin
Copy link
Member

duplicate of #4458

@samuelcolvin
Copy link
Member

This is slightly different but should be easy to fix in #4469.

@samuelcolvin
Copy link
Member

After some consideration and discussions, I've decided to fix this by reverting #4224 in #4470.

See #4470 for a full explanation.

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

Successfully merging a pull request may close this issue.

3 participants