Skip to content

Commit f54e821

Browse files
committed
some small fixes
1 parent 4a1f299 commit f54e821

File tree

4 files changed

+95
-11
lines changed

4 files changed

+95
-11
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
intersystems_iris>=3.3.0b8
1+
intersystems_iris>=3.3.0b9
22
SQLAlchemy>=1.4

sqlalchemy_iris/base.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ def visit_delete(self, delete_stmt, **kw):
365365
text = super().visit_delete(delete_stmt, **kw)
366366
return text
367367

368+
def for_update_clause(self, select, **kw):
369+
return ""
370+
368371
def visit_true(self, expr, **kw):
369372
return "1"
370373

@@ -425,7 +428,7 @@ def _add_exact(column):
425428

426429
_order_by_clauses = [
427430
sql_util.unwrap_label_reference(elem)
428-
for elem in select._order_by_clause.clauses
431+
for elem in select._order_by_clause.clauses if isinstance(elem, schema.Column)
429432
]
430433
if _order_by_clauses:
431434
select._raw_columns = [
@@ -508,6 +511,19 @@ def visit_column(self, column, within_columns_clause=False, **kwargs):
508511
text = 'CONVERT(VARCHAR, %s)' % (text, )
509512
return text
510513

514+
def visit_concat_op_binary(self, binary, operator, **kw):
515+
return "STRING(%s, %s)" % (
516+
self.process(binary.left, **kw),
517+
self.process(binary.right, **kw),
518+
)
519+
520+
def visit_mod_binary(self, binary, operator, **kw):
521+
return (
522+
self.process(binary.left, **kw)
523+
+ " # "
524+
+ self.process(binary.right, **kw)
525+
)
526+
511527

512528
class IRISDDLCompiler(sql.compiler.DDLCompiler):
513529
"""IRIS syntactic idiosyncrasies"""
@@ -519,8 +535,12 @@ def visit_drop_schema(self, drop, **kw):
519535
return ""
520536

521537
def visit_check_constraint(self, constraint, **kw):
522-
raise exc.CompileError("Check CONSTRAINT not supported")
523-
# pass
538+
pass
539+
540+
def visit_add_constraint(self, create, **kw):
541+
if isinstance(create.element, schema.CheckConstraint):
542+
raise exc.CompileError("Can't add CHECK constraint")
543+
return super().visit_add_constraint(create, **kw)
524544

525545
def visit_computed_column(self, generated, **kwargs):
526546
text = self.sql_compiler.process(
@@ -706,6 +726,9 @@ def __init__(self, **kwargs):
706726
]
707727
)
708728

729+
def _get_default_schema_name(self, connection):
730+
return IRISDialect.default_schema_name
731+
709732
def _get_option(self, connection, option):
710733
cursor = connection.cursor()
711734
# cursor = connection.cursor()
@@ -751,6 +774,27 @@ def dbapi(cls):
751774
# dbapi.paramstyle = "format"
752775
return dbapi
753776

777+
def is_disconnect(self, e, connection, cursor):
778+
if isinstance(e, self.dbapi.InterfaceError):
779+
return "Connection is closed" in str(e)
780+
return False
781+
782+
def do_ping(self, dbapi_connection):
783+
cursor = None
784+
try:
785+
cursor = dbapi_connection.cursor()
786+
try:
787+
cursor.execute(self._dialect_specific_select_one)
788+
finally:
789+
cursor.close()
790+
except self.dbapi.Error as err:
791+
if self.is_disconnect(err, dbapi_connection, cursor):
792+
return False
793+
else:
794+
raise
795+
else:
796+
return True
797+
754798
def create_connect_args(self, url):
755799
opts = {}
756800
opts["hostname"] = url.host

sqlalchemy_iris/requirements.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,50 @@ def precision_numerics_many_significant_digits(self):
126126
def symbol_names_w_double_quote(self):
127127
"""Target driver can create tables with a name like 'some " table'"""
128128
return exclusions.closed()
129+
130+
@property
131+
def unique_constraint_reflection(self):
132+
return exclusions.open()
133+
134+
@property
135+
def index_reflects_included_columns(self):
136+
return exclusions.open()
137+
138+
@property
139+
def intersect(self):
140+
"""Target database must support INTERSECT or equivalent."""
141+
return exclusions.closed()
142+
143+
@property
144+
def except_(self):
145+
"""Target database must support EXCEPT or equivalent (i.e. MINUS)."""
146+
return exclusions.closed()
147+
148+
@property
149+
def boolean_col_expressions(self):
150+
"""Target database must support boolean expressions as columns"""
151+
152+
return exclusions.closed()
153+
154+
@property
155+
def order_by_label_with_expression(self):
156+
"""target backend supports ORDER BY a column label within an
157+
expression.
158+
159+
Basically this::
160+
161+
select data as foo from test order by foo || 'bar'
162+
163+
Lots of databases including PostgreSQL don't support this,
164+
so this is off by default.
165+
166+
"""
167+
return exclusions.closed()
168+
169+
@property
170+
def memory_process_intensive(self):
171+
"""Driver is able to handle the memory tests which run in a subprocess
172+
and iterate through hundreds of connections
173+
174+
"""
175+
return exclusions.closed()

test/test_suite.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from sqlalchemy.testing.suite import QuotedNameArgumentTest as _QuotedNameArgumentTest
21
from sqlalchemy.testing.suite import FetchLimitOffsetTest as _FetchLimitOffsetTest
32
from sqlalchemy.testing.suite import CompoundSelectTest as _CompoundSelectTest
43
from sqlalchemy.testing import fixtures
5-
# from sqlalchemy.testing import AssertsExecutionResults, AssertsCompiledSQL
64
from sqlalchemy import testing
75
from sqlalchemy import Table, Column, Integer, String, select
86
import pytest
@@ -16,11 +14,6 @@ def test_limit_offset_aliased_selectable_in_unions(self):
1614
return
1715

1816

19-
@pytest.mark.skip()
20-
class QuotedNameArgumentTest(_QuotedNameArgumentTest):
21-
pass
22-
23-
2417
class FetchLimitOffsetTest(_FetchLimitOffsetTest):
2518

2619
def test_simple_offset_no_order(self, connection):

0 commit comments

Comments
 (0)