Skip to content

Commit 5eb62b0

Browse files
committed
binary types
1 parent 5d5ec90 commit 5eb62b0

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

sqlalchemy_iris/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,8 @@ class IRISDialect(default.DefaultDialect):
817817

818818
supports_sequences = False
819819

820+
returns_native_bytes = True
821+
820822
div_is_floordiv = False
821823

822824
postfetch_lastrowid = True

tests/test_suite.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
from sqlalchemy.testing.suite import CTETest as _CTETest
44
from sqlalchemy.testing.suite import DifficultParametersTest as _DifficultParametersTest
55
from sqlalchemy.testing import fixtures
6+
from sqlalchemy.testing.assertions import eq_
7+
from sqlalchemy.testing import config
68
from sqlalchemy.orm import Session
79
from sqlalchemy import testing
8-
from sqlalchemy import Table, Column, Integer, String, select
10+
from sqlalchemy import Table, Column, select
11+
from sqlalchemy.types import Integer
12+
from sqlalchemy.types import String
13+
from sqlalchemy.types import VARBINARY
14+
from sqlalchemy.types import BINARY
915
import pytest
1016

1117
from sqlalchemy.testing.suite import * # noqa
@@ -149,4 +155,35 @@ def test_exists(self):
149155
.where(self.tables.users.c.user_name == "nope")
150156
.exists()
151157
).scalar()
152-
158+
159+
160+
class IRISBinaryTest(fixtures.TablesTest):
161+
__backend__ = True
162+
163+
@classmethod
164+
def define_tables(cls, metadata):
165+
Table(
166+
"data",
167+
metadata,
168+
Column("bin1", BINARY(50)),
169+
Column("bin2", VARBINARY(50)),
170+
)
171+
172+
@classmethod
173+
def insert_data(cls, connection):
174+
connection.execute(
175+
cls.tables.data.insert(),
176+
[
177+
{"bin1": b"test", "bin2": b"test"},
178+
],
179+
)
180+
181+
def _assert_result(self, select, result):
182+
with config.db.connect() as conn:
183+
eq_(conn.execute(select).fetchall(), result)
184+
185+
def test_expect_bytes(self):
186+
self._assert_result(
187+
select(self.tables.data),
188+
[(b"test", b"test")],
189+
)

0 commit comments

Comments
 (0)