Skip to content

Commit

Permalink
Merge pull request #285 from Net-Mist/parsing_tests
Browse files Browse the repository at this point in the history
fix(parsing): change the way to quote db_url to fix the test broken by sqlalchemy 2.0.25
  • Loading branch information
xzkostyan committed Feb 17, 2024
2 parents c5eda6d + 4a4931f commit dc378ec
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sa-versions.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: [push, pull_request]
name: "SQLAlchemy >=2.0.18 versions"
name: "SQLAlchemy >=2.0.25 versions"
jobs:
tests:
runs-on: ubuntu-20.04
Expand All @@ -9,7 +9,7 @@ jobs:
- "3.12"
clickhouse-version:
- 23.8.4.69
sa-version: [18, 19, 20, 21, 22]
sa-version: [25]

name: ${{ matrix.python-version }} SA=2.0.${{ matrix.sa-version }}
steps:
Expand Down
6 changes: 2 additions & 4 deletions clickhouse_sqlalchemy/drivers/native/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from urllib.parse import quote

from sqlalchemy.sql.elements import TextClause
from sqlalchemy.util import asbool

Expand Down Expand Up @@ -54,10 +52,10 @@ def import_dbapi(cls):
def create_connect_args(self, url):
url = url.set(drivername='clickhouse')
if url.username:
url = url.set(username=quote(url.username))
url = url.set(username=url.username)

if url.password:
url = url.set(password=quote(url.password))
url = url.set(password=url.password)

self.engine_reflection = asbool(
url.query.get('engine_reflection', 'true')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def read_version():
packages=find_packages('.', exclude=["tests*"]),
python_requires='>=3.7, <4',
install_requires=[
'sqlalchemy>=2.0.0,<2.1.0',
'sqlalchemy>=2.0.25,<2.1.0',
'requests',
'clickhouse-driver>=0.1.2',
'asynch>=0.2.2',
Expand Down
18 changes: 15 additions & 3 deletions tests/drivers/native/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,23 @@ def test_no_auth(self):
)

def test_quoting(self):
user = quote('us#er')
password = quote(' pass#word')
user = "us#er"
password = 'pass#word'
part = '{}:{}@host/database'.format(user, password)
quote_user = quote(user)
quote_password = quote(password)
quote_part = '{}:{}@host/database'.format(quote_user, quote_password)

# test with unquote user and password
url = make_url('clickhouse+native://' + part)
connect_args = self.dialect.create_connect_args(url)
self.assertEqual(
str(connect_args[0][0]), 'clickhouse://' + part
str(connect_args[0][0]), 'clickhouse://' + quote_part
)

# test with quote user and password
url = make_url('clickhouse+native://' + quote_part)
connect_args = self.dialect.create_connect_args(url)
self.assertEqual(
str(connect_args[0][0]), 'clickhouse://' + quote_part
)
2 changes: 1 addition & 1 deletion testsrequire.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

tests_require = [
'pytest',
'sqlalchemy>=2.0.0,<2.1.0',
'sqlalchemy>=2.0.25,<2.1.0',
'greenlet>=2.0.1',
'alembic',
'requests',
Expand Down

0 comments on commit dc378ec

Please sign in to comment.