From: Jason Kirtland Date: Tue, 21 Aug 2007 01:31:23 +0000 (+0000) Subject: - omitted 'table' and 'column' from 'from sqlalchemy import *' X-Git-Tag: rel_0_4beta4~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6228e72cb15be6e84260440d20369c91858b4640;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - omitted 'table' and 'column' from 'from sqlalchemy import *' - also omitted all modules and classes that aren't expicitly public - omitted 'Smallinteger' (small i), but it's still in schema - omitted NullType-related items from types.__all__ - patched up a few tests to use sql.table and sql.column, other related. --- diff --git a/CHANGES b/CHANGES index 96f4433927..9974f08cf3 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,20 @@ CHANGES 0.4.0beta4 ---------- +- Tidied up what ends up in your namespace when you 'from sqlalchemy import *': + + - 'table' and 'column' are no longer imported. They remain available by + direct reference (as in 'sql.table' and 'sql.column') or a glob import + from the sql package. It was too easy to accidentally use a + sql.expressions.table instead of schema.Table when just starting out + with SQLAlchemy, likewise column. + + - internal-ish classes like ClauseElement, FromClause, NullTypeEngine, etc., + are also no longer imported into your namespace + + - the 'Smallinteger' compatiblity name (small i!) is no longer imported, but + remains in schema.py for now. SmallInteger (big I!) is still imported. + - Fix to bind param processing such that "False" values (like blank strings) still get processed/encoded. @@ -1292,7 +1306,7 @@ CHANGES - added example/docs for dealing with large collections - added object_session() method to sqlalchemy namespace - fixed QueuePool bug whereby its better able to reconnect to a database -that was not reachable (thanks to Sébastien Lelong), also fixed dispose() +that was not reachable (thanks to Sébastien Lelong), also fixed dispose() method - patch that makes MySQL rowcount work correctly! [ticket:396] - fix to MySQL catch of 2006/2014 errors to properly re-raise OperationalError diff --git a/lib/sqlalchemy/__init__.py b/lib/sqlalchemy/__init__.py index bdd3604de9..601d36b7bb 100644 --- a/lib/sqlalchemy/__init__.py +++ b/lib/sqlalchemy/__init__.py @@ -4,9 +4,27 @@ # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -from sqlalchemy.types import * -from sqlalchemy.sql import * -from sqlalchemy.schema import * +from sqlalchemy.types import ( + BLOB, BOOLEAN, CHAR, CLOB, DATE, DATETIME, DECIMAL, FLOAT, INT, + NCHAR, SMALLINT, TEXT, TIME, TIMESTAMP, VARCHAR, + Binary, Boolean, Date, DateTime, Float, Integer, Interval, Numeric, + PickleType, SmallInteger, String, Time, Unicode + ) +from sqlalchemy.sql import ( + func, modifier, text, literal, literal_column, null, alias, + and_, or_, not_, + select, subquery, union, union_all, insert, update, delete, + join, outerjoin, + bindparam, outparam, asc, desc, + except_, except_all, exists, intersect, intersect_all, + between, case, cast, distinct, extract, + ) +from sqlalchemy.schema import ( + MetaData, ThreadLocalMetaData, Table, Column, ForeignKey, + Sequence, Index, ForeignKeyConstraint, PrimaryKeyConstraint, + CheckConstraint, UniqueConstraint, Constraint, + PassiveDefault, ColumnDefault + ) from sqlalchemy.engine import create_engine, engine_from_config diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 0b3253420d..833d2cf159 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -4,11 +4,13 @@ # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -__all__ = [ 'TypeEngine', 'TypeDecorator', 'NullTypeEngine', +__all__ = [ 'TypeEngine', 'TypeDecorator', 'INT', 'CHAR', 'VARCHAR', 'NCHAR', 'TEXT', 'FLOAT', 'DECIMAL', - 'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN', 'String', 'Integer', 'SmallInteger','Smallinteger', - 'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary', 'Boolean', 'Unicode', 'PickleType', 'NULLTYPE', 'NullType', - 'SMALLINT', 'DATE', 'TIME','Interval' + 'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN', + 'SMALLINT', 'DATE', 'TIME', + 'String', 'Integer', 'SmallInteger','Smallinteger', + 'Numeric', 'Float', 'DateTime', 'Date', 'Time', 'Binary', + 'Boolean', 'Unicode', 'PickleType', 'Interval', ] import inspect diff --git a/test/base/utils.py b/test/base/utils.py index 97f3db06fc..8df3a2b97d 100644 --- a/test/base/utils.py +++ b/test/base/utils.py @@ -1,5 +1,5 @@ import testbase -from sqlalchemy import util, column, sql, exceptions +from sqlalchemy import util, sql, exceptions from testlib import * @@ -37,9 +37,9 @@ class OrderedDictTest(PersistTest): class ColumnCollectionTest(PersistTest): def test_in(self): cc = sql.ColumnCollection() - cc.add(column('col1')) - cc.add(column('col2')) - cc.add(column('col3')) + cc.add(sql.column('col1')) + cc.add(sql.column('col2')) + cc.add(sql.column('col3')) assert 'col1' in cc assert 'col2' in cc @@ -53,9 +53,9 @@ class ColumnCollectionTest(PersistTest): cc1 = sql.ColumnCollection() cc2 = sql.ColumnCollection() cc3 = sql.ColumnCollection() - c1 = column('col1') + c1 = sql.column('col1') c2 = c1.label('col2') - c3 = column('col3') + c3 = sql.column('col3') cc1.add(c1) cc2.add(c2) cc3.add(c3) diff --git a/test/dialect/mssql.py b/test/dialect/mssql.py index 781f27029f..eeadde2ffd 100755 --- a/test/dialect/mssql.py +++ b/test/dialect/mssql.py @@ -1,6 +1,7 @@ import testbase import re from sqlalchemy import * +from sqlalchemy.sql import table, column from sqlalchemy.databases import mssql from testlib import * diff --git a/test/dialect/oracle.py b/test/dialect/oracle.py index 9f194bf070..a717a7338f 100644 --- a/test/dialect/oracle.py +++ b/test/dialect/oracle.py @@ -1,5 +1,6 @@ import testbase from sqlalchemy import * +from sqlalchemy.sql import table, column from sqlalchemy.databases import oracle from testlib import * diff --git a/test/orm/relationships.py b/test/orm/relationships.py index 305cdb6082..e628b20b58 100644 --- a/test/orm/relationships.py +++ b/test/orm/relationships.py @@ -1,6 +1,7 @@ import testbase import datetime from sqlalchemy import * +from sqlalchemy import types from sqlalchemy.orm import * from sqlalchemy.orm import collections from sqlalchemy.orm.collections import collection @@ -674,7 +675,7 @@ class TypedAssociationTable(ORMTest): def define_tables(self, metadata): global t1, t2, t3 - class MySpecialType(TypeDecorator): + class MySpecialType(types.TypeDecorator): impl = String def convert_bind_param(self, value, dialect): return "lala" + value diff --git a/test/sql/generative.py b/test/sql/generative.py index 9bd97b3054..ece8a8d055 100644 --- a/test/sql/generative.py +++ b/test/sql/generative.py @@ -1,5 +1,6 @@ import testbase from sqlalchemy import * +from sqlalchemy.sql import table, column, ClauseElement from testlib import * from sqlalchemy.sql.visitors import * diff --git a/test/sql/query.py b/test/sql/query.py index ddd5348c45..4e68fb980b 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -1,7 +1,7 @@ import testbase import datetime from sqlalchemy import * -from sqlalchemy import exceptions +from sqlalchemy import exceptions, sql from sqlalchemy.engine import default from testlib import * @@ -397,7 +397,7 @@ class QueryTest(PersistTest): w = select(['*'], from_obj=[testbase.db.func.current_date()]).scalar() # construct a column-based FROM object out of a function, like in [ticket:172] - s = select([column('date', type_=DateTime)], from_obj=[testbase.db.func.current_date()]) + s = select([sql.column('date', type_=DateTime)], from_obj=[testbase.db.func.current_date()]) q = s.execute().fetchone()[s.c.date] r = s.alias('datequery').select().scalar() diff --git a/test/sql/select.py b/test/sql/select.py index c075d4e3b4..2d3f579547 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -2,6 +2,7 @@ import testbase import re, operator from sqlalchemy import * from sqlalchemy import util +from sqlalchemy.sql import table, column from sqlalchemy.databases import sqlite, postgres, mysql, oracle, firebird, mssql from testlib import * diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index e355436ec1..f4a9d3c703 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -188,7 +188,7 @@ class ColumnsTest(AssertMixin): print db.engine.__module__ testTable = Table('testColumns', MetaData(db), Column('int_column', Integer), - Column('smallint_column', Smallinteger), + Column('smallint_column', SmallInteger), Column('varchar_column', String(20)), Column('numeric_column', Numeric(12,3)), Column('float_column', Float(25)),