Skip to content

Commit c51572f

Browse files
authored
fix: DriverDialect.is_dialect may return false for different driver classes (#523)
1 parent 66e3203 commit c51572f

9 files changed

+16
-12
lines changed

aws_advanced_python_wrapper/connection_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
from threading import Lock
2626

2727
from aws_advanced_python_wrapper.errors import AwsWrapperError
28-
from aws_advanced_python_wrapper.hostselector import (HostSelector,
29-
RandomHostSelector,
30-
RoundRobinHostSelector)
28+
from aws_advanced_python_wrapper.host_selector import (HostSelector,
29+
RandomHostSelector,
30+
RoundRobinHostSelector)
3131
from aws_advanced_python_wrapper.plugin import CanReleaseResources
3232
from aws_advanced_python_wrapper.utils.log import Logger
3333
from aws_advanced_python_wrapper.utils.messages import Messages

aws_advanced_python_wrapper/fastest_response_strategy_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
Set, Tuple)
2424

2525
from aws_advanced_python_wrapper.errors import AwsWrapperError
26-
from aws_advanced_python_wrapper.hostselector import RandomHostSelector
26+
from aws_advanced_python_wrapper.host_selector import RandomHostSelector
2727
from aws_advanced_python_wrapper.plugin import Plugin
2828
from aws_advanced_python_wrapper.utils.cache_map import CacheMap
2929
from aws_advanced_python_wrapper.utils.log import Logger

aws_advanced_python_wrapper/mysql_driver_dialect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class MySQLDriverDialect(DriverDialect):
6363
}
6464

6565
def is_dialect(self, connect_func: Callable) -> bool:
66-
return MySQLDriverDialect.TARGET_DRIVER_CODE in str(signature(connect_func))
66+
if MySQLDriverDialect.TARGET_DRIVER_CODE not in str(signature(connect_func)):
67+
return MySQLDriverDialect.TARGET_DRIVER_CODE.lower() in (connect_func.__module__ + connect_func.__qualname__).lower()
68+
return True
6769

6870
def is_closed(self, conn: Connection) -> bool:
6971
if isinstance(conn, CMySQLConnection) or isinstance(conn, MySQLConnection):

aws_advanced_python_wrapper/pg_driver_dialect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class PgDriverDialect(DriverDialect):
5858
}
5959

6060
def is_dialect(self, connect_func: Callable) -> bool:
61-
return PgDriverDialect.TARGET_DRIVER_CODE in str(signature(connect_func))
61+
if PgDriverDialect.TARGET_DRIVER_CODE not in str(signature(connect_func)):
62+
return PgDriverDialect.TARGET_DRIVER_CODE.lower() in (connect_func.__module__ + connect_func.__qualname__).lower()
63+
return True
6264

6365
def is_closed(self, conn: Connection) -> bool:
6466
if isinstance(conn, psycopg.Connection):

aws_advanced_python_wrapper/sql_alchemy_connection_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
from aws_advanced_python_wrapper.connection_provider import ConnectionProvider
2727
from aws_advanced_python_wrapper.errors import AwsWrapperError
28-
from aws_advanced_python_wrapper.hostselector import (HostSelector,
29-
RandomHostSelector,
30-
RoundRobinHostSelector)
28+
from aws_advanced_python_wrapper.host_selector import (HostSelector,
29+
RandomHostSelector,
30+
RoundRobinHostSelector)
3131
from aws_advanced_python_wrapper.plugin import CanReleaseResources
3232
from aws_advanced_python_wrapper.utils.messages import Messages
3333
from aws_advanced_python_wrapper.utils.properties import (Properties,

tests/unit/test_host_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import pytest
1717

1818
from aws_advanced_python_wrapper import pep249
19+
from aws_advanced_python_wrapper.host_selector import RandomHostSelector
1920
from aws_advanced_python_wrapper.hostinfo import HostInfo, HostRole
20-
from aws_advanced_python_wrapper.hostselector import RandomHostSelector
2121

2222

2323
def test_random_host_selection_strategy():

tests/unit/test_random_host_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import pytest
1616

1717
from aws_advanced_python_wrapper.host_availability import HostAvailability
18+
from aws_advanced_python_wrapper.host_selector import RandomHostSelector
1819
from aws_advanced_python_wrapper.hostinfo import HostInfo, HostRole
19-
from aws_advanced_python_wrapper.hostselector import RandomHostSelector
2020
from aws_advanced_python_wrapper.utils.properties import Properties
2121

2222
HOST_ROLE = HostRole.READER

tests/unit/test_round_robin_host_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
from aws_advanced_python_wrapper.errors import AwsWrapperError
1818
from aws_advanced_python_wrapper.host_availability import HostAvailability
19+
from aws_advanced_python_wrapper.host_selector import RoundRobinHostSelector
1920
from aws_advanced_python_wrapper.hostinfo import HostInfo, HostRole
20-
from aws_advanced_python_wrapper.hostselector import RoundRobinHostSelector
2121
from aws_advanced_python_wrapper.utils.properties import (Properties,
2222
WrapperProperties)
2323

0 commit comments

Comments
 (0)