Skip to content

Commit a576a67

Browse files
committed
Add test of types
1 parent bea552b commit a576a67

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

test/test_core.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,21 @@ def test_select_types(self, connection):
209209
row = connection.execute(sa.select(tb)).fetchone()
210210
assert row == (1, "Hello World!", 3.5, True, now, today)
211211

212+
def test_integer_types(self, connection):
213+
stmt = sa.Select(
214+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_uint8", 8, types.UInt8))),
215+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_uint16", 16, types.UInt16))),
216+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_uint32", 32, types.UInt32))),
217+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_uint64", 64, types.UInt64))),
218+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_int8", -8, types.Int8))),
219+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_int16", -16, types.Int16))),
220+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_int32", -32, types.Int32))),
221+
sa.func.FormatType(sa.func.TypeOf(sa.bindparam("p_int64", -64, types.Int64))),
222+
)
223+
224+
result = connection.execute(stmt).fetchone()
225+
assert result == (b"Uint8", b"Uint16", b"Uint32", b"Uint64", b"Int8", b"Int16", b"Int32", b"Int64")
226+
212227

213228
class TestWithClause(TablesTest):
214229
run_create_tables = "each"

ydb_sqlalchemy/sqlalchemy/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ def visit_uint16(self, type_: types.UInt16, **kw):
9999
def visit_uint8(self, type_: types.UInt8, **kw):
100100
return "UInt8"
101101

102-
def visit_int64(self, type_: types.UInt64, **kw):
102+
def visit_int64(self, type_: types.Int64, **kw):
103103
return "Int64"
104104

105-
def visit_int32(self, type_: types.UInt32, **kw):
105+
def visit_int32(self, type_: types.Int32, **kw):
106106
return "Int32"
107107

108-
def visit_int16(self, type_: types.UInt16, **kw):
108+
def visit_int16(self, type_: types.Int16, **kw):
109109
return "Int16"
110110

111-
def visit_int8(self, type_: types.UInt8, **kw):
111+
def visit_int8(self, type_: types.Int8, **kw):
112112
return "Int8"
113113

114114
def visit_INTEGER(self, type_: sa.INTEGER, **kw):

ydb_sqlalchemy/sqlalchemy/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class UInt32(types.Integer):
1212

1313

1414
class UInt16(types.Integer):
15-
__visit_name__ = "uint32"
15+
__visit_name__ = "uint16"
1616

1717

1818
class UInt8(types.Integer):

0 commit comments

Comments
 (0)