Skip to content

Commit adbb4f3

Browse files
committed
fix for TINYINT
1 parent e6430dc commit adbb4f3

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

sqlalchemy_iris/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,9 @@ def visit_LONGVARBINARY(self, type_, **kw):
745745
def visit_DOUBLE(self, type_, **kw):
746746
return "DOUBLE"
747747

748+
def visit_TINYINT(self, type_, **kw):
749+
return "TINYINT"
750+
748751

749752
class IRISIdentifierPreparer(sql.compiler.IdentifierPreparer):
750753
"""Install IRIS specific reserved words."""

tests/test_suite.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from sqlalchemy.types import String
1515
from sqlalchemy.types import VARBINARY
1616
from sqlalchemy.types import BINARY
17+
from sqlalchemy_iris import TINYINT
18+
from sqlalchemy.exc import DatabaseError
1719
import pytest
1820

1921
from sqlalchemy.testing.suite import * # noqa
@@ -71,6 +73,39 @@ def test_simple_limit_offset_no_order(self, connection, cases):
7173
)
7274

7375

76+
class TinyintTest(fixtures.TablesTest):
77+
__backend__ = True
78+
79+
@classmethod
80+
def define_tables(cls, metadata):
81+
Table(
82+
"test_tinyint",
83+
metadata,
84+
Column("val_tinyint", TINYINT),
85+
)
86+
87+
@testing.fixture
88+
def local_connection(self):
89+
with testing.db.connect() as conn:
90+
yield conn
91+
92+
def test_commits(self, local_connection):
93+
test_tinyint = self.tables.test_tinyint
94+
connection = local_connection
95+
96+
transaction = connection.begin()
97+
connection.execute(test_tinyint.insert(), dict(val_tinyint=100))
98+
with pytest.raises(DatabaseError):
99+
connection.execute(test_tinyint.insert(), dict(val_tinyint=129))
100+
with pytest.raises(DatabaseError):
101+
connection.execute(test_tinyint.insert(), dict(val_tinyint=-129))
102+
transaction.commit()
103+
104+
result = connection.exec_driver_sql("select * from test_tinyint")
105+
assert len(result.fetchall()) == 1
106+
connection.close()
107+
108+
74109
class TransactionTest(fixtures.TablesTest):
75110
__backend__ = True
76111

0 commit comments

Comments
 (0)