Skip to content

Commit

Permalink
Fix AttributeError: module 'sqlalchemy.types' has no attribute 'DOUBL…
Browse files Browse the repository at this point in the history
…E' (fix #526) (#527)
  • Loading branch information
laughingman7743 committed Mar 18, 2024
1 parent 0c8c8b1 commit 254266a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pyathena/sqlalchemy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@
ischema_names: Dict[str, Type[Any]] = {
"boolean": types.BOOLEAN,
"float": types.FLOAT,
"double": types.DOUBLE,
# TODO: types.DOUBLE is not defined in SQLAlchemy 1.4.
"double": types.FLOAT,
"real": types.FLOAT,
"tinyint": TINYINT,
"smallint": types.SMALLINT,
Expand Down
17 changes: 12 additions & 5 deletions tests/pyathena/sqlalchemy/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ def test_reflect_select(self, engine):
assert isinstance(one_row_complex.c.col_int.type, types.INTEGER)
assert isinstance(one_row_complex.c.col_bigint.type, types.BIGINT)
assert isinstance(one_row_complex.c.col_float.type, types.FLOAT)
assert isinstance(one_row_complex.c.col_double.type, types.DOUBLE)
# TODO: types.DOUBLE is not defined in SQLAlchemy 1.4.
assert isinstance(one_row_complex.c.col_double.type, types.FLOAT)
assert isinstance(one_row_complex.c.col_string.type, types.String)
assert isinstance(one_row_complex.c.col_varchar.type, types.VARCHAR)
assert one_row_complex.c.col_varchar.type.length == 10
Expand Down Expand Up @@ -307,7 +308,8 @@ def test_get_column_type(self, engine):
assert isinstance(dialect._get_column_type("int"), types.INTEGER)
assert isinstance(dialect._get_column_type("bigint"), types.BIGINT)
assert isinstance(dialect._get_column_type("float"), types.FLOAT)
assert isinstance(dialect._get_column_type("double"), types.DOUBLE)
# TODO: types.DOUBLE is not defined in SQLAlchemy 1.4.
assert isinstance(dialect._get_column_type("double"), types.FLOAT)
assert isinstance(dialect._get_column_type("real"), types.FLOAT)
assert isinstance(dialect._get_column_type("string"), types.String)
assert isinstance(dialect._get_column_type("varchar"), types.VARCHAR)
Expand Down Expand Up @@ -1890,9 +1892,14 @@ def test_numeric_type_variants(self, engine):
assert type(actual.c.col_integer2.type) in [types.INT, types.INTEGER, types.Integer]
assert type(actual.c.col_bigint.type) in [types.BIGINT, types.BigInteger]
assert type(actual.c.col_biginteger.type) in [types.BIGINT, types.BigInteger]
assert type(actual.c.col_double1.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
assert type(actual.c.col_double2.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
assert type(actual.c.col_double_precision.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
assert type(actual.c.col_double1.type) in [types.FLOAT, types.Float]
assert type(actual.c.col_double2.type) in [types.FLOAT, types.Float]
assert type(actual.c.col_double_precision.type) in [types.FLOAT, types.Float]
# TODO: types.DOUBLE is not defined in SQLAlchemy 1.4.
# assert type(actual.c.col_double_precision.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
# assert type(actual.c.col_double1.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
# assert type(actual.c.col_double2.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
# assert type(actual.c.col_double_precision.type) in [types.DOUBLE, types.Double, types.DOUBLE_PRECISION]
assert type(actual.c.col_float1.type) in [types.FLOAT, types.Float]
assert type(actual.c.col_float2.type) in [types.FLOAT, types.Float]
assert type(actual.c.col_decimal.type) in [types.DECIMAL]

0 comments on commit 254266a

Please sign in to comment.