Skip to content

Commit 3fb2502

Browse files
committed
fixed concat function
1 parent 355c657 commit 3fb2502

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

sqlalchemy_iris/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,12 @@ def visit_concat_op_binary(self, binary, operator, **kw):
591591
self.process(binary.right, **kw),
592592
)
593593

594+
def visit_concat_func(
595+
self, func, **kw
596+
):
597+
args = [self.process(clause, **kw) for clause in func.clauses.clauses]
598+
return ' || '.join(args)
599+
594600
def visit_mod_binary(self, binary, operator, **kw):
595601
return (
596602
self.process(binary.left, **kw) + " # " + self.process(binary.right, **kw)
@@ -955,6 +961,11 @@ def _set_option(self, connection, option, value):
955961
return row[0]
956962
return None
957963

964+
def get_isolation_level_values(self, dbapi_connection):
965+
levels = set(self._isolation_lookup)
966+
levels.add("AUTOCOMMIT")
967+
return levels
968+
958969
def get_isolation_level(self, connection):
959970
try:
960971
level = int(self._get_option(connection, "IsolationMode"))

tests/test_suite.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
from sqlalchemy.testing import config
1010
from sqlalchemy.orm import Session
1111
from sqlalchemy import testing
12-
from sqlalchemy import Table, Column, select
12+
from sqlalchemy import Table, Column, select, func
1313
from sqlalchemy.types import Integer
1414
from sqlalchemy.types import String
1515
from sqlalchemy.types import VARBINARY
16+
from sqlalchemy.types import TEXT
1617
from sqlalchemy.types import BINARY
1718
from sqlalchemy_iris import TINYINT
1819
from sqlalchemy_iris import INTEGER
@@ -440,3 +441,48 @@ def test_max_inner_product(self):
440441
(2,),
441442
],
442443
)
444+
445+
446+
class ConcatTest(fixtures.TablesTest):
447+
__backend__ = True
448+
449+
@classmethod
450+
def define_tables(cls, metadata):
451+
Table(
452+
"data",
453+
metadata,
454+
Column("sometext", TEXT),
455+
Column("testdata", TEXT),
456+
)
457+
458+
@classmethod
459+
def fixtures(cls):
460+
return dict(
461+
data=(
462+
(
463+
"sometext",
464+
"testdata",
465+
),
466+
(
467+
"sometestdata",
468+
"test",
469+
),
470+
)
471+
)
472+
473+
def _assert_result(self, select, result):
474+
with config.db.connect() as conn:
475+
eq_(conn.execute(select).fetchall(), result)
476+
477+
def test_concat_func(self):
478+
self._assert_result(
479+
select(
480+
self.tables.data.c.sometext,
481+
).filter(
482+
self.tables.data.c.sometext
483+
== func.concat("some", self.tables.data.c.testdata, "data")
484+
),
485+
[
486+
("sometestdata",),
487+
],
488+
)

0 commit comments

Comments
 (0)