Skip to content

Commit 24f9d7c

Browse files
committed
fix(mssql): infer bit as boolean everywhere
1 parent 296cd7d commit 24f9d7c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

ibis/backends/base/sql/alchemy/datatypes.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from typing import Iterable
55

66
import sqlalchemy as sa
7-
from sqlalchemy.dialects import mysql, postgresql, sqlite
7+
from sqlalchemy.dialects import mssql, mysql, postgresql, sqlite
8+
from sqlalchemy.dialects.mssql.base import MSDialect
89
from sqlalchemy.dialects.mysql.base import MySQLDialect
910
from sqlalchemy.dialects.postgresql.base import PGDialect
1011
from sqlalchemy.dialects.sqlite.base import SQLiteDialect
@@ -235,6 +236,11 @@ def sa_mysql_tinyint(_, satype, nullable=True):
235236
return dt.Int8(nullable=nullable)
236237

237238

239+
@dt.dtype.register(MSDialect, mssql.BIT)
240+
def sa_mysql_bit(_, satype, nullable=True):
241+
return dt.Boolean(nullable=nullable)
242+
243+
238244
@dt.dtype.register(Dialect, sa.types.BigInteger)
239245
def sa_bigint(_, satype, nullable=True):
240246
return dt.Int64(nullable=nullable)

ibis/backends/mssql/datatypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _type_from_result_set_info(col: _FieldDescription) -> dt.DataType:
3838
_type_mapping = {
3939
# Exact numerics
4040
'BIGINT': dt.Int64,
41-
'BIT': dt.Int8,
41+
'BIT': dt.Boolean,
4242
'DECIMAL': dt.Decimal,
4343
'INT': dt.Int32,
4444
'MONEY': dt.Int64,

ibis/backends/mssql/tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
DB_TYPES = [
88
# Exact numbers
99
('BIGINT', dt.int64),
10-
('BIT', dt.int8),
10+
('BIT', dt.boolean),
1111
('DECIMAL', dt.Decimal(precision=18, scale=0)),
1212
('DECIMAL(5, 2)', dt.Decimal(precision=5, scale=2)),
1313
('INT', dt.int32),

0 commit comments

Comments
 (0)