Skip to content

Commit 6a66d7d

Browse files
committed
updated driver
1 parent 1396e36 commit 6a66d7d

File tree

4 files changed

+49
-36
lines changed

4 files changed

+49
-36
lines changed

requirements-iris.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/intersystems-community/intersystems-irispython/releases/download/3.9.1/intersystems_iris-3.9.1-py3-none-any.whl
1+
https://github.com/intersystems-community/intersystems-irispython/releases/download/3.9.2/intersystems_iris-3.9.2-py3-none-any.whl

sqlalchemy_iris/base.py

+17-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
2+
from decimal import Decimal
23
import intersystems_iris.dbapi._DBAPI as dbapi
3-
import intersystems_iris._IRISNative as IRISNative
44
from . import information_schema as ischema
55
from sqlalchemy import exc
66
from sqlalchemy.orm import aliased
@@ -888,6 +888,8 @@ class IRISDialect(default.DefaultDialect):
888888

889889
supports_vectors = None
890890

891+
supports_cte = True
892+
891893
colspecs = colspecs
892894

893895
ischema_names = ischema_names
@@ -949,8 +951,8 @@ def on_connect(conn):
949951
self.supports_vectors = False
950952
self._dictionary_access = False
951953
with conn.cursor() as cursor:
952-
cursor.execute("%CHECKPRIV SELECT ON %Dictionary.PropertyDefinition")
953-
self._dictionary_access = cursor.sqlcode == 0
954+
res = cursor.execute("%CHECKPRIV SELECT ON %Dictionary.PropertyDefinition")
955+
self._dictionary_access = res == 0
954956

955957
# if not self.supports_vectors:
956958
# util.warn("No native support for VECTOR or not activated by license")
@@ -1061,14 +1063,14 @@ def create_connect_args(self, url):
10611063
_debug_queries = False
10621064
# _debug_queries = True
10631065

1064-
def _debug(self, query, params, many=False):
1065-
from decimal import Decimal
1066-
1066+
def _debug(self, query, params, many=False, wrap=True):
10671067
if not self._debug_queries:
10681068
return
10691069
if many:
1070+
print("-" * 120)
10701071
for p in params:
1071-
self._debug(query, p)
1072+
self._debug(query, p, wrap=False)
1073+
print("-" * 120)
10721074
return
10731075
for p in params:
10741076
if isinstance(p, Decimal):
@@ -1078,21 +1080,11 @@ def _debug(self, query, params, many=False):
10781080
else:
10791081
v = "%r" % (p,)
10801082
query = query.replace("?", v, 1)
1081-
print("--")
1083+
if wrap:
1084+
print("-" * 120)
10821085
print(query + ";")
1083-
print("--")
1084-
1085-
def _debug_pre(self, query, params, many=False):
1086-
print("-- do_execute" + "many" if many else "")
1087-
if not self._debug_queries:
1088-
return
1089-
for line in query.split("\n"):
1090-
print("-- ", line)
1091-
if many:
1092-
print(params)
1093-
else:
1094-
for p in params:
1095-
print("-- @param = %r" % (p,))
1086+
if wrap:
1087+
print("-" * 120)
10961088

10971089
def do_execute(self, cursor, query, params, context=None):
10981090
if query.endswith(";"):
@@ -1746,8 +1738,10 @@ def get_multi_columns(
17461738
coltype = coltype(**kwargs)
17471739

17481740
default = "" if default == "$c(0)" else default
1749-
if default and default.startswith('"'):
1750-
default = "'%s'" % (default[1:-1].replace("'", "''"),)
1741+
if default:
1742+
default = str(default)
1743+
if default.startswith('"'):
1744+
default = "'%s'" % (default[1:-1].replace("'", "''"),)
17511745

17521746
cdict = {
17531747
"name": name,

sqlalchemy_iris/requirements.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class AlembicRequirements(BaseRequirements):
1515

1616

1717
class Requirements(SuiteRequirements, AlembicRequirements):
18+
1819
@property
1920
def array_type(self):
2021
return exclusions.closed()
@@ -68,11 +69,10 @@ def comment_reflection(self):
6869

6970
@property
7071
def insert_returning(self):
71-
return exclusions.open()
72-
73-
@property
74-
def unusual_column_name_characters(self):
75-
return exclusions.open()
72+
return exclusions.skip_if(
73+
lambda config: not config.db.dialect.insert_returning,
74+
"driver doesn't support insert returning",
75+
)
7676

7777
@property
7878
def computed_columns(self):
@@ -211,8 +211,10 @@ def memory_process_intensive(self):
211211
@property
212212
def ctes(self):
213213
"""Target database supports CTEs"""
214-
215-
return exclusions.open()
214+
return exclusions.skip_if(
215+
lambda config: not config.db.dialect.supports_cte,
216+
"driver doesn't support CTEs",
217+
)
216218

217219
@property
218220
def ctes_with_update_delete(self):

tests/conftest.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from sqlalchemy.dialects import registry
22
import pytest
3-
import time
43
import os
54

65
from sqlalchemy.testing.plugin.plugin_base import pre
@@ -12,12 +11,15 @@
1211
registry.register(
1312
"iris.irisasync", "sqlalchemy_iris.irisasync", "IRISDialect_irisasync"
1413
)
14+
registry.register(
15+
"iris.intersystems", "sqlalchemy_iris.intersystems", "IRISDialect_intersystems"
16+
)
1517

1618
pytest.register_assert_rewrite("sqlalchemy.testing.assertions")
1719

1820
from sqlalchemy.testing.plugin.pytestplugin import * # noqa
1921

20-
original_pytest_addoption = pytest_addoption
22+
original_pytest_addoption = pytest_addoption # noqa
2123

2224

2325
def pytest_addoption(parser):
@@ -33,6 +35,14 @@ def pytest_addoption(parser):
3335
help="Docker image with IRIS",
3436
)
3537

38+
group.addoption(
39+
"--driver",
40+
action="store",
41+
default=None,
42+
type=str,
43+
help="Driver",
44+
)
45+
3646

3747
@pre
3848
def start_container(opt, file_config):
@@ -47,11 +57,18 @@ def start_container(opt, file_config):
4757
username="sqlalchemy",
4858
password="sqlalchemy",
4959
namespace="TEST",
50-
license_key=os.path.expanduser("~/iris.key") if "community" not in opt.container else None,
60+
license_key=(
61+
os.path.expanduser("~/iris.key")
62+
if "community" not in opt.container
63+
else None
64+
),
5165
)
5266
iris.start()
53-
print("dburi:", iris.get_connection_url())
54-
opt.dburi = [iris.get_connection_url()]
67+
dburi = iris.get_connection_url()
68+
if opt.driver:
69+
dburi = dburi.replace("iris://", f"iris+{opt.driver}://")
70+
print("dburi:", dburi)
71+
opt.dburi = [dburi]
5572

5673

5774
def pytest_unconfigure(config):

0 commit comments

Comments
 (0)