From a29245e247698160172e42e2154180997b81b8ba Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 13 Jun 2012 17:55:10 -0400 Subject: [PATCH] - [bug] Added BIGINT, BINARY, VARBINARY to types.__all__, sqlalchemy namespaces, plus tests to make sure new types remain importable. [ticket:2499] --- CHANGES | 8 ++++++-- lib/sqlalchemy/__init__.py | 3 +++ lib/sqlalchemy/types.py | 2 +- test/sql/test_types.py | 25 ++++++++++++++++--------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 947395fd92..517f5f5539 100644 --- a/CHANGES +++ b/CHANGES @@ -308,8 +308,12 @@ CHANGES propagating the exception onward normally. also in 0.7.7. - - [bug] Add BINARY, VARBINARY to types.__all__, - [ticket:2474] Also in 0.7.7 + - [bug] Added BIGINT, BINARY, VARBINARY to + types.__all__, sqlalchemy namespaces, + plus tests to make sure new types + remain importable. [ticket:2474] + also in 0.7.7, [ticket:2499] also + in 0.7.8. - sqlite - [feature] the SQLite date and time types diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index d8534dd495..08efee600d 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -48,6 +48,8 @@ from sqlalchemy.sql import ( ) from sqlalchemy.types import ( + BIGINT, + BINARY, BLOB, BOOLEAN, BigInteger, @@ -85,6 +87,7 @@ from sqlalchemy.types import ( TypeDecorator, Unicode, UnicodeText, + VARBINARY, VARCHAR, ) diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index a45f769f6d..6f30156dde 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -14,7 +14,7 @@ For more information see the SQLAlchemy documentation on types. __all__ = [ 'TypeEngine', 'TypeDecorator', 'AbstractType', 'UserDefinedType', 'INT', 'CHAR', 'VARCHAR', 'NCHAR', 'NVARCHAR','TEXT', 'Text', 'FLOAT', 'NUMERIC', 'REAL', 'DECIMAL', 'TIMESTAMP', 'DATETIME', - 'CLOB', 'BLOB', 'BINARY', 'VARBINARY', 'BOOLEAN', 'SMALLINT', + 'CLOB', 'BLOB', 'BINARY', 'VARBINARY', 'BOOLEAN', 'BIGINT', 'SMALLINT', 'INTEGER', 'DATE', 'TIME', 'String', 'Integer', 'SmallInteger', 'BigInteger', 'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'LargeBinary', 'Binary', 'Boolean', 'Unicode', 'Concatenable', diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 951e1551d8..659c7f2ae3 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -29,20 +29,27 @@ class AdaptTest(fixtures.TestBase): return [d.base.dialect() for d in self._all_dialect_modules()] - def _all_types(self): - def types_for_mod(mod): - for key in dir(mod): - typ = getattr(mod, key) - if not isinstance(typ, type) or not issubclass(typ, types.TypeEngine): - continue - yield typ + def _types_for_mod(self, mod): + for key in dir(mod): + typ = getattr(mod, key) + if not isinstance(typ, type) or not issubclass(typ, types.TypeEngine): + continue + yield typ - for typ in types_for_mod(types): + def _all_types(self): + for typ in self._types_for_mod(types): yield typ for dialect in self._all_dialect_modules(): - for typ in types_for_mod(dialect): + for typ in self._types_for_mod(dialect): yield typ + def test_uppercase_importable(self): + import sqlalchemy as sa + for typ in self._types_for_mod(types): + if typ.__name__ == typ.__name__.upper(): + assert getattr(sa, typ.__name__) is typ + assert typ.__name__ in types.__all__ + def test_uppercase_rendering(self): """Test that uppercase types from types.py always render as their type. -- 2.47.3