Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43751: Change default type mapping for boolean to BOOLEAN for MySQL #56

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/felis/db/sqltypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def compile_tinyint(type_: Any, compiler: Any, **kw: Any) -> str:

_TypeMap = Mapping[str, types.TypeEngine | type[types.TypeEngine]]

boolean_map: _TypeMap = {MYSQL: mysql.BIT(1), ORACLE: oracle.NUMBER(1), POSTGRES: postgresql.BOOLEAN()}
boolean_map: _TypeMap = {MYSQL: mysql.BOOLEAN, ORACLE: oracle.NUMBER(1), POSTGRES: postgresql.BOOLEAN()}

byte_map: _TypeMap = {
MYSQL: mysql.TINYINT(),
Expand Down
11 changes: 5 additions & 6 deletions tests/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def test_mysql_datatypes(self) -> None:
with self.assertRaises(ValidationError):
coldata.col("int", "INTEGER")

with self.assertRaises(ValidationError):
coldata.col("boolean", "BIT(1)")

with self.assertRaises(ValidationError):
coldata.col("float", "FLOAT")

Expand All @@ -82,9 +79,8 @@ def test_mysql_datatypes(self) -> None:
with self.assertRaises(ValidationError):
coldata.col("long", "BIGINT")

# These look like they should be equivalent, but the default is
# actually ``BIT(1)`` for MySQL.
coldata.col("boolean", "BOOLEAN")
with self.assertRaises(ValidationError):
coldata.col("boolean", "BOOLEAN")

with self.assertRaises(ValidationError):
coldata.col("unicode", "NVARCHAR", length=32)
Expand All @@ -102,6 +98,9 @@ def test_mysql_datatypes(self) -> None:
# Same type and length
coldata.col("string", "VARCHAR(128)", length=128)
JeremyMcCormick marked this conversation as resolved.
Show resolved Hide resolved

# Check the old type mapping for MySQL, which is now okay
coldata.col("boolean", "BIT(1)")

# Different types, which is okay
coldata.col("double", "FLOAT")

Expand Down