mirror of
https://github.com/jazzband/dj-database-url.git
synced 2026-03-16 22:20:24 +00:00
fix: parse options with numerical values as int (#225)
* fix: parse options with numerical values as int fixes #222 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
9b0f325910
commit
13be1aa9b9
2 changed files with 11 additions and 1 deletions
|
|
@ -162,7 +162,10 @@ def parse(
|
|||
options["ssl"] = {"ca": values[-1]}
|
||||
continue
|
||||
|
||||
options[key] = values[-1]
|
||||
try:
|
||||
options[key] = int(values[-1])
|
||||
except (TypeError, ValueError):
|
||||
options[key] = values[-1]
|
||||
|
||||
if ssl_require:
|
||||
options["sslmode"] = "require"
|
||||
|
|
|
|||
|
|
@ -585,6 +585,13 @@ class DatabaseTestSuite(unittest.TestCase):
|
|||
url = dj_database_url.config(ssl_require=True)
|
||||
assert url["OPTIONS"] == {'sslmode': 'require'}
|
||||
|
||||
def test_options_int_values(self):
|
||||
"""Ensure that options with integer values are parsed correctly."""
|
||||
url = dj_database_url.parse(
|
||||
"mysql://user:pw@127.0.0.1:15036/db?connect_timout=3"
|
||||
)
|
||||
assert url["OPTIONS"] == {'connect_timout': 3}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue