Skip to content

Commit

Permalink
Add warnings for unsupported ODBC functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gordthompson committed Aug 29, 2020
1 parent d11dbde commit ba8e317
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 0 additions & 1 deletion _pypi_test_upload.bat

This file was deleted.

2 changes: 1 addition & 1 deletion sqlalchemy_access/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import pyodbc

__version__ = "1.0.7b1"
__version__ = "1.0.7"

pyodbc.pooling = False # required for Access databases with ODBC linked tables
_registry.register(
Expand Down
18 changes: 18 additions & 0 deletions sqlalchemy_access/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"""
import warnings

from sqlalchemy import types, exc, pool
from sqlalchemy.sql import compiler
from sqlalchemy.engine import default, reflection
Expand Down Expand Up @@ -724,6 +726,14 @@ def get_pk_constraint(self, connection, table_name, schema=None, **kw):
except pyodbc.InterfaceError as ie:
if ie.args[0] == "IM001":
# ('IM001', '[IM001] [Microsoft][ODBC Driver Manager] Driver does not support this function (0) (SQLPrimaryKeys)')
warnings.warn(
(
'The Access ODBC driver does not support the ODBC "SQLPrimaryKeys" function. '
"get_pk_constraint() is returning an empty list."
),
exc.SAWarning,
stacklevel=3,
)
return []
else:
raise
Expand All @@ -738,6 +748,14 @@ def get_foreign_keys(self, connection, table_name, schema=None, **kw):
except pyodbc.InterfaceError as ie:
if ie.args[0] == "IM001":
# ('IM001', '[IM001] [Microsoft][ODBC Driver Manager] Driver does not support this function (0) (SQLForeignKeys)')
warnings.warn(
(
'The Access ODBC driver does not support the ODBC "SQLForeignKeys" function. '
"get_foreign_keys() is returning an empty list."
),
exc.SAWarning,
stacklevel=3,
)
return []
else:
raise
Expand Down
15 changes: 15 additions & 0 deletions test/test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ComponentReflectionTest as _ComponentReflectionTest,
)
from sqlalchemy.testing.suite import DateTimeTest as _DateTimeTest
from sqlalchemy.testing.suite import ExistsTest as _ExistsTest
from sqlalchemy.testing.suite import (
ExpandingBoundInTest as _ExpandingBoundInTest,
)
Expand Down Expand Up @@ -55,6 +56,20 @@ def test_null_bound_comparison(cls):
return


class ExistsTest(_ExistsTest):
@pytest.mark.skip()
def test_select_exists(cls):
# bypass this test because Access ODBC fails with
# "SELECT statement includes a reserved word or an argument name ..."
return

@pytest.mark.skip()
def test_select_exists_false(cls):
# bypass this test because Access ODBC fails with
# "SELECT statement includes a reserved word or an argument name ..."
return


class ExpandingBoundInTest(_ExpandingBoundInTest):
@pytest.mark.skip()
def test_null_in_empty_set_is_false(cls):
Expand Down

0 comments on commit ba8e317

Please sign in to comment.