Skip to content

Commit

Permalink
fix: DriverDialect.is_dialect may return false for different driver c…
Browse files Browse the repository at this point in the history
…lasses (#523)
  • Loading branch information
karenc-bq authored May 8, 2024
1 parent 66e3203 commit c51572f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 12 deletions.
6 changes: 3 additions & 3 deletions aws_advanced_python_wrapper/connection_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from threading import Lock

from aws_advanced_python_wrapper.errors import AwsWrapperError
from aws_advanced_python_wrapper.hostselector import (HostSelector,
RandomHostSelector,
RoundRobinHostSelector)
from aws_advanced_python_wrapper.host_selector import (HostSelector,
RandomHostSelector,
RoundRobinHostSelector)
from aws_advanced_python_wrapper.plugin import CanReleaseResources
from aws_advanced_python_wrapper.utils.log import Logger
from aws_advanced_python_wrapper.utils.messages import Messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Set, Tuple)

from aws_advanced_python_wrapper.errors import AwsWrapperError
from aws_advanced_python_wrapper.hostselector import RandomHostSelector
from aws_advanced_python_wrapper.host_selector import RandomHostSelector
from aws_advanced_python_wrapper.plugin import Plugin
from aws_advanced_python_wrapper.utils.cache_map import CacheMap
from aws_advanced_python_wrapper.utils.log import Logger
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion aws_advanced_python_wrapper/mysql_driver_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class MySQLDriverDialect(DriverDialect):
}

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

def is_closed(self, conn: Connection) -> bool:
if isinstance(conn, CMySQLConnection) or isinstance(conn, MySQLConnection):
Expand Down
4 changes: 3 additions & 1 deletion aws_advanced_python_wrapper/pg_driver_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class PgDriverDialect(DriverDialect):
}

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

def is_closed(self, conn: Connection) -> bool:
if isinstance(conn, psycopg.Connection):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

from aws_advanced_python_wrapper.connection_provider import ConnectionProvider
from aws_advanced_python_wrapper.errors import AwsWrapperError
from aws_advanced_python_wrapper.hostselector import (HostSelector,
RandomHostSelector,
RoundRobinHostSelector)
from aws_advanced_python_wrapper.host_selector import (HostSelector,
RandomHostSelector,
RoundRobinHostSelector)
from aws_advanced_python_wrapper.plugin import CanReleaseResources
from aws_advanced_python_wrapper.utils.messages import Messages
from aws_advanced_python_wrapper.utils.properties import (Properties,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_host_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import pytest

from aws_advanced_python_wrapper import pep249
from aws_advanced_python_wrapper.host_selector import RandomHostSelector
from aws_advanced_python_wrapper.hostinfo import HostInfo, HostRole
from aws_advanced_python_wrapper.hostselector import RandomHostSelector


def test_random_host_selection_strategy():
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_random_host_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import pytest

from aws_advanced_python_wrapper.host_availability import HostAvailability
from aws_advanced_python_wrapper.host_selector import RandomHostSelector
from aws_advanced_python_wrapper.hostinfo import HostInfo, HostRole
from aws_advanced_python_wrapper.hostselector import RandomHostSelector
from aws_advanced_python_wrapper.utils.properties import Properties

HOST_ROLE = HostRole.READER
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_round_robin_host_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

from aws_advanced_python_wrapper.errors import AwsWrapperError
from aws_advanced_python_wrapper.host_availability import HostAvailability
from aws_advanced_python_wrapper.host_selector import RoundRobinHostSelector
from aws_advanced_python_wrapper.hostinfo import HostInfo, HostRole
from aws_advanced_python_wrapper.hostselector import RoundRobinHostSelector
from aws_advanced_python_wrapper.utils.properties import (Properties,
WrapperProperties)

Expand Down

0 comments on commit c51572f

Please sign in to comment.