[Sqlalchemy-commits] sqlalchemy: merge default. includes the pep8 stuff.
Brought to you by:
zzzeek
From: <co...@sq...> - 2012-12-02 01:20:37
|
details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/586d5e5052f0 changeset: 8970:586d5e5052f0 user: Mike Bayer <mi...@zz...> date: Sat Dec 01 20:20:18 2012 -0500 description: merge default. includes the pep8 stuff. diffstat: doc/build/changelog/changelog_08.rst | 74 ++- doc/build/conf.py | 1 - doc/build/dialects/postgresql.rst | 2 +- doc/build/orm/session.rst | 26 +- lib/sqlalchemy/connectors/__init__.py | 1 - lib/sqlalchemy/connectors/mxodbc.py | 10 +- lib/sqlalchemy/connectors/mysqldb.py | 9 +- lib/sqlalchemy/connectors/pyodbc.py | 23 +- lib/sqlalchemy/connectors/zxJDBC.py | 1 + lib/sqlalchemy/dialects/__init__.py | 3 +- lib/sqlalchemy/dialects/drizzle/base.py | 10 - lib/sqlalchemy/dialects/firebird/__init__.py | 4 +- lib/sqlalchemy/dialects/firebird/base.py | 39 +- lib/sqlalchemy/dialects/firebird/fdb.py | 3 +- lib/sqlalchemy/dialects/firebird/kinterbasdb.py | 4 +- lib/sqlalchemy/dialects/informix/__init__.py | 2 +- lib/sqlalchemy/dialects/informix/base.py | 102 +- lib/sqlalchemy/dialects/informix/informixdb.py | 2 + lib/sqlalchemy/dialects/mssql/__init__.py | 2 +- lib/sqlalchemy/dialects/mssql/adodbapi.py | 11 +- lib/sqlalchemy/dialects/mssql/base.py | 106 ++- lib/sqlalchemy/dialects/mssql/information_schema.py | 2 +- lib/sqlalchemy/dialects/mssql/mxodbc.py | 14 +- lib/sqlalchemy/dialects/mssql/pymssql.py | 7 +- lib/sqlalchemy/dialects/mssql/pyodbc.py | 5 +- lib/sqlalchemy/dialects/mssql/zxjdbc.py | 1 + lib/sqlalchemy/dialects/mysql/base.py | 86 +- lib/sqlalchemy/dialects/mysql/gaerdbms.py | 2 +- lib/sqlalchemy/dialects/mysql/mysqlconnector.py | 6 +- lib/sqlalchemy/dialects/mysql/mysqldb.py | 2 + lib/sqlalchemy/dialects/mysql/oursql.py | 79 +- lib/sqlalchemy/dialects/mysql/pymysql.py | 4 +- lib/sqlalchemy/dialects/mysql/pyodbc.py | 2 + lib/sqlalchemy/dialects/mysql/zxjdbc.py | 3 +- lib/sqlalchemy/dialects/oracle/base.py | 104 +- lib/sqlalchemy/dialects/oracle/cx_oracle.py | 53 +- lib/sqlalchemy/dialects/oracle/zxjdbc.py | 13 +- lib/sqlalchemy/dialects/postgresql/base.py | 190 ++++-- lib/sqlalchemy/dialects/postgresql/hstore.py | 21 +- lib/sqlalchemy/dialects/postgresql/pg8000.py | 9 +- lib/sqlalchemy/dialects/postgresql/psycopg2.py | 42 +- lib/sqlalchemy/dialects/postgresql/pypostgresql.py | 9 +- lib/sqlalchemy/dialects/postgresql/zxjdbc.py | 4 +- lib/sqlalchemy/dialects/sqlite/__init__.py | 7 +- lib/sqlalchemy/dialects/sqlite/base.py | 178 +++-- lib/sqlalchemy/dialects/sqlite/pysqlite.py | 104 +- lib/sqlalchemy/dialects/sybase/__init__.py | 22 +- lib/sqlalchemy/dialects/sybase/base.py | 107 +- lib/sqlalchemy/dialects/sybase/mxodbc.py | 5 +- lib/sqlalchemy/dialects/sybase/pyodbc.py | 9 +- lib/sqlalchemy/dialects/sybase/pysybase.py | 8 +- lib/sqlalchemy/engine/__init__.py | 17 +- lib/sqlalchemy/engine/base.py | 85 +- lib/sqlalchemy/engine/ddl.py | 39 +- lib/sqlalchemy/engine/default.py | 26 +- lib/sqlalchemy/engine/interfaces.py | 150 +++- lib/sqlalchemy/engine/reflection.py | 48 +- lib/sqlalchemy/engine/result.py | 2 + lib/sqlalchemy/engine/strategies.py | 30 +- lib/sqlalchemy/engine/threadlocal.py | 28 +- lib/sqlalchemy/engine/url.py | 22 +- lib/sqlalchemy/engine/util.py | 5 +- lib/sqlalchemy/event.py | 21 +- lib/sqlalchemy/events.py | 56 +- lib/sqlalchemy/exc.py | 54 +- lib/sqlalchemy/ext/__init__.py | 1 - lib/sqlalchemy/ext/associationproxy.py | 83 +- lib/sqlalchemy/ext/compiler.py | 110 ++- lib/sqlalchemy/ext/declarative/__init__.py | 80 +- lib/sqlalchemy/ext/declarative/api.py | 14 +- lib/sqlalchemy/ext/declarative/base.py | 20 +- lib/sqlalchemy/ext/declarative/clsregistry.py | 19 +- lib/sqlalchemy/ext/horizontal_shard.py | 34 +- lib/sqlalchemy/ext/hybrid.py | 16 +- lib/sqlalchemy/ext/instrumentation.py | 26 +- lib/sqlalchemy/ext/mutable.py | 115 ++- lib/sqlalchemy/ext/orderinglist.py | 60 +- lib/sqlalchemy/ext/serializer.py | 31 +- lib/sqlalchemy/inspection.py | 5 +- lib/sqlalchemy/interfaces.py | 17 +- lib/sqlalchemy/log.py | 8 +- lib/sqlalchemy/orm/__init__.py | 133 ++- lib/sqlalchemy/orm/attributes.py | 44 +- lib/sqlalchemy/orm/collections.py | 21 +- lib/sqlalchemy/orm/dependency.py | 49 +- lib/sqlalchemy/orm/deprecated_interfaces.py | 12 +- lib/sqlalchemy/orm/descriptor_props.py | 33 +- lib/sqlalchemy/orm/dynamic.py | 18 +- lib/sqlalchemy/orm/evaluator.py | 4 +- lib/sqlalchemy/orm/events.py | 159 ++-- lib/sqlalchemy/orm/exc.py | 18 +- lib/sqlalchemy/orm/identity.py | 20 +- lib/sqlalchemy/orm/instrumentation.py | 7 +- lib/sqlalchemy/orm/interfaces.py | 74 +- lib/sqlalchemy/orm/loading.py | 25 +- lib/sqlalchemy/orm/mapper.py | 20 +- lib/sqlalchemy/orm/persistence.py | 26 +- lib/sqlalchemy/orm/properties.py | 39 +- lib/sqlalchemy/orm/query.py | 208 +++--- lib/sqlalchemy/orm/relationships.py | 85 +- lib/sqlalchemy/orm/scoping.py | 14 +- lib/sqlalchemy/orm/session.py | 365 ++++++----- lib/sqlalchemy/orm/state.py | 5 +- lib/sqlalchemy/orm/strategies.py | 150 +++- lib/sqlalchemy/orm/sync.py | 23 +- lib/sqlalchemy/orm/unitofwork.py | 14 +- lib/sqlalchemy/orm/util.py | 215 +++++- lib/sqlalchemy/pool.py | 100 ++- lib/sqlalchemy/processors.py | 5 +- lib/sqlalchemy/schema.py | 193 ++++-- lib/sqlalchemy/sql/__init__.py | 1 - lib/sqlalchemy/sql/compiler.py | 127 ++-- lib/sqlalchemy/sql/expression.py | 146 +++- lib/sqlalchemy/sql/functions.py | 28 +- lib/sqlalchemy/sql/operators.py | 45 +- lib/sqlalchemy/sql/util.py | 57 +- lib/sqlalchemy/sql/visitors.py | 44 +- lib/sqlalchemy/testing/__init__.py | 5 +- lib/sqlalchemy/testing/assertions.py | 27 +- lib/sqlalchemy/testing/assertsql.py | 9 +- lib/sqlalchemy/testing/config.py | 1 - lib/sqlalchemy/testing/engines.py | 31 +- lib/sqlalchemy/testing/entities.py | 6 + lib/sqlalchemy/testing/exclusions.py | 19 + lib/sqlalchemy/testing/fixtures.py | 15 +- lib/sqlalchemy/testing/pickleable.py | 57 +- lib/sqlalchemy/testing/plugin/noseplugin.py | 17 +- lib/sqlalchemy/testing/profiling.py | 47 +- lib/sqlalchemy/testing/requirements.py | 7 +- lib/sqlalchemy/testing/runner.py | 1 + lib/sqlalchemy/testing/schema.py | 3 +- lib/sqlalchemy/testing/suite/test_ddl.py | 4 +- lib/sqlalchemy/testing/suite/test_insert.py | 5 +- lib/sqlalchemy/testing/suite/test_reflection.py | 4 +- lib/sqlalchemy/testing/suite/test_types.py | 16 +- lib/sqlalchemy/testing/suite/test_update_delete.py | 6 +- lib/sqlalchemy/testing/util.py | 10 +- lib/sqlalchemy/testing/warnings.py | 4 + lib/sqlalchemy/types.py | 266 +++++--- lib/sqlalchemy/util/__init__.py | 7 +- lib/sqlalchemy/util/_collections.py | 45 +- lib/sqlalchemy/util/compat.py | 15 +- lib/sqlalchemy/util/deprecations.py | 5 + lib/sqlalchemy/util/langhelpers.py | 62 +- lib/sqlalchemy/util/queue.py | 3 + lib/sqlalchemy/util/topological.py | 4 + test/aaa_profiling/test_memusage.py | 6 +- test/dialect/test_postgresql.py | 90 ++- test/engine/test_pool.py | 78 ++- test/ext/declarative/test_basic.py | 41 +- test/orm/inheritance/test_polymorphic_rel.py | 38 +- test/orm/inheritance/test_relationship.py | 243 +++++++- test/orm/inheritance/test_single.py | 3 +- test/orm/test_eager_relations.py | 6 +- test/orm/test_inspect.py | 6 +- test/orm/test_joins.py | 30 +- test/orm/test_mapper.py | 1 - test/orm/test_query.py | 45 +- test/orm/test_relationships.py | 58 +- test/orm/test_subquery_relations.py | 51 +- test/orm/test_utils.py | 254 ++++++- test/profiles.txt | 10 +- test/sql/test_labels.py | 348 ++++++---- test/sql/test_quote.py | 602 ++++++++++++++++--- 164 files changed, 5247 insertions(+), 2646 deletions(-) diffs (truncated from 21708 to 300 lines): diff -r 6c6dd05943fd -r 586d5e5052f0 doc/build/changelog/changelog_08.rst --- a/doc/build/changelog/changelog_08.rst Sun Nov 18 12:36:24 2012 -0500 +++ b/doc/build/changelog/changelog_08.rst Sat Dec 01 20:20:18 2012 -0500 @@ -7,6 +7,38 @@ :version: 0.8.0b2 .. change:: + :tags: firebird, bug + :tickets: 2622 + + Added missing import for "fdb" to the experimental + "firebird+fdb" dialect. + + .. change:: + :tags: orm, feature + + Allow synonyms to be used when defining primary and secondary + joins for relationships. + + .. change:: + :tags: orm, bug + :tickets: 2614 + + A second overhaul of aliasing/internal pathing mechanics + now allows two subclasses to have different relationships + of the same name, supported with subquery or joined eager + loading on both simultaneously when a full polymorphic + load is used. + + .. change:: + :tags: orm, bug + :tickets: 2617 + + Fixed bug whereby a multi-hop subqueryload within + a particular with_polymorphic load would produce a KeyError. + Takes advantage of the same internal pathing overhaul + as :ticket:`2614`. + + .. change:: :tags: sql, bug Fixed a gotcha where inadvertently calling list() on a @@ -114,6 +146,46 @@ Support for reflection of the "name" of primary key constraints added, courtesy Dave Moore. + .. change:: + :tags: informix + + Some cruft regarding informix transaction handling has been + removed, including a feature that would skip calling + commit()/rollback() as well as some hardcoded isolation level + assumptions on begin().. The status of this dialect is not + well understood as we don't have any users working with it, + nor any access to an Informix database. If someone with + access to Informix wants to help test this dialect, please + let us know. + + .. change:: + :tags: pool, feature + + The :class:`.Pool` will now log all connection.close() + operations equally, including closes which occur for + invalidated connections, detached connections, and connections + beyond the pool capacity. + + .. change:: + :tags: pool, feature + :tickets: 2611 + + The :class:`.Pool` now consults the :class:`.Dialect` for + functionality regarding how the connection should be + "auto rolled back", as well as closed. This grants more + control of transaction scope to the dialect, so that we + will be better able to implement transactional workarounds + like those potentially needed for pysqlite and cx_oracle. + + .. change:: + :tags: pool, feature + + Added new :meth:`.PoolEvents.reset` hook to capture + the event before a connection is auto-rolled back, upon + return to the pool. Together with + :meth:`.ConnectionEvents.rollback` this allows all rollback + events to be intercepted. + .. changelog:: :version: 0.8.0b1 :released: October 30, 2012 @@ -1479,4 +1551,4 @@ :tags: sql, removed The long-deprecated and non-functional ``assert_unicode`` flag on - :func:`.create_engine` as well as :class:`.String` is removed. \ No newline at end of file + :func:`.create_engine` as well as :class:`.String` is removed. diff -r 6c6dd05943fd -r 586d5e5052f0 doc/build/conf.py --- a/doc/build/conf.py Sun Nov 18 12:36:24 2012 -0500 +++ b/doc/build/conf.py Sat Dec 01 20:20:18 2012 -0500 @@ -33,7 +33,6 @@ extensions = [ 'sphinx.ext.autodoc', - # 'sphinx.ext.doctest', 'builder.autodoc_mods', 'builder.changelog', 'builder.dialect_info', diff -r 6c6dd05943fd -r 586d5e5052f0 doc/build/dialects/postgresql.rst --- a/doc/build/dialects/postgresql.rst Sun Nov 18 12:36:24 2012 -0500 +++ b/doc/build/dialects/postgresql.rst Sat Dec 01 20:20:18 2012 -0500 @@ -26,7 +26,7 @@ .. autoclass:: array .. autoclass:: ARRAY - :members: __init__ + :members: __init__, Comparator :show-inheritance: .. autoclass:: BIT diff -r 6c6dd05943fd -r 586d5e5052f0 doc/build/orm/session.rst --- a/doc/build/orm/session.rst Sun Nov 18 12:36:24 2012 -0500 +++ b/doc/build/orm/session.rst Sat Dec 01 20:20:18 2012 -0500 @@ -1295,6 +1295,7 @@ print "Skipped record %s" % record session.commit() +.. _session_autocommit: Autocommit Mode --------------- @@ -1309,16 +1310,21 @@ still occurs within the scope of a single transaction, though this transaction is closed out after the :meth:`.Session.flush` operation completes. -"autocommit" mode should **not be considered for general use**. While -very old versions of SQLAlchemy standardized on this mode, the modern -:class:`.Session` benefits highly from being given a clear point of transaction -demarcation via :meth:`.Session.rollback` and :meth:`.Session.commit`. -The autoflush action can safely emit SQL to the database as needed without -implicitly producing permanent effects, the contents of attributes -are expired only when a logical series of steps has completed. If the -:class:`.Session` were to be used in pure "autocommit" mode without -an ongoing transaction, these features should be disabled, that is, -``autoflush=False, expire_on_commit=False``. +.. warning:: + + "autocommit" mode should **not be considered for general use**. + If used, it should always be combined with the usage of + :meth:`.Session.begin` and :meth:`.Session.commit`, to ensure + a transaction demarcation. + + Executing queries outside of a demarcated transaction is a legacy mode + of usage, and can in some cases lead to concurrent connection + checkouts. + + In the absense of a demarcated transaction, the :class:`.Session` + cannot make appropriate decisions as to when autoflush should + occur nor when auto-expiration should occur, so these features + should be disabled with ``autoflush=False, expire_on_commit=False``. Modern usage of "autocommit" is for framework integrations that need to control specifically when the "begin" state occurs. A session which is configured with diff -r 6c6dd05943fd -r 586d5e5052f0 lib/sqlalchemy/connectors/__init__.py --- a/lib/sqlalchemy/connectors/__init__.py Sun Nov 18 12:36:24 2012 -0500 +++ b/lib/sqlalchemy/connectors/__init__.py Sat Dec 01 20:20:18 2012 -0500 @@ -7,4 +7,3 @@ class Connector(object): pass - diff -r 6c6dd05943fd -r 586d5e5052f0 lib/sqlalchemy/connectors/mxodbc.py --- a/lib/sqlalchemy/connectors/mxodbc.py Sun Nov 18 12:36:24 2012 -0500 +++ b/lib/sqlalchemy/connectors/mxodbc.py Sat Dec 01 20:20:18 2012 -0500 @@ -24,8 +24,9 @@ from . import Connector + class MxODBCConnector(Connector): - driver='mxodbc' + driver = 'mxodbc' supports_sane_multi_rowcount = False supports_unicode_statements = True @@ -47,7 +48,7 @@ elif platform == 'darwin': from mx.ODBC import iODBC as module else: - raise ImportError, "Unrecognized platform for mxODBC import" + raise ImportError("Unrecognized platform for mxODBC import") return module @classmethod @@ -73,8 +74,8 @@ emit Python standard warnings. """ from mx.ODBC.Error import Warning as MxOdbcWarning + def error_handler(connection, cursor, errorclass, errorvalue): - if issubclass(errorclass, MxOdbcWarning): errorclass.__bases__ = (Warning,) warnings.warn(message=str(errorvalue), @@ -141,7 +142,8 @@ return True def do_executemany(self, cursor, statement, parameters, context=None): - cursor.executemany(statement, parameters, direct=self._get_direct(context)) + cursor.executemany( + statement, parameters, direct=self._get_direct(context)) def do_execute(self, cursor, statement, parameters, context=None): cursor.execute(statement, parameters, direct=self._get_direct(context)) diff -r 6c6dd05943fd -r 586d5e5052f0 lib/sqlalchemy/connectors/mysqldb.py --- a/lib/sqlalchemy/connectors/mysqldb.py Sun Nov 18 12:36:24 2012 -0500 +++ b/lib/sqlalchemy/connectors/mysqldb.py Sat Dec 01 20:20:18 2012 -0500 @@ -10,9 +10,11 @@ from .. import exc, log, schema, sql, types as sqltypes, util, processors import re + # the subclassing of Connector by all classes # here is not strictly necessary + class MySQLDBExecutionContext(Connector): @property @@ -22,6 +24,7 @@ else: return self.cursor.rowcount + class MySQLDBCompiler(Connector): def visit_mod_binary(self, binary, operator, **kw): return self.process(binary.left, **kw) + " %% " + \ @@ -30,12 +33,14 @@ def post_process_text(self, text): return text.replace('%', '%%') + class MySQLDBIdentifierPreparer(Connector): def _escape_identifier(self, value): value = value.replace(self.escape_quote, self.escape_to_quote) return value.replace("%", "%%") + class MySQLDBConnector(Connector): driver = 'mysqldb' supports_unicode_statements = False @@ -76,7 +81,8 @@ # query string. ssl = {} - for key in ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher']: + keys = ['ssl_ca', 'ssl_key', 'ssl_cert', 'ssl_capath', 'ssl_cipher'] + for key in keys: if key in opts: ssl[key[4:]] = opts[key] util.coerce_kw_type(ssl, key[4:], str) @@ -148,4 +154,3 @@ "combination of MySQL server and MySQL-python. " "MySQL-python >= 1.2.2 is recommended. Assuming latin1.") return 'latin1' - diff -r 6c6dd05943fd -r 586d5e5052f0 lib/sqlalchemy/connectors/pyodbc.py --- a/lib/sqlalchemy/connectors/pyodbc.py Sun Nov 18 12:36:24 2012 -0500 +++ b/lib/sqlalchemy/connectors/pyodbc.py Sat Dec 01 20:20:18 2012 -0500 @@ -11,8 +11,9 @@ import re import urllib + class PyODBCConnector(Connector): - driver='pyodbc' + driver = 'pyodbc' supports_sane_multi_rowcount = False # PyODBC unicode is broken on UCS-4 builds @@ -63,7 +64,7 @@ dsn_connection = 'dsn' in keys or \ ('host' in keys and 'database' not in keys) if dsn_connection: - connectors= ['dsn=%s' % (keys.pop('host', '') or \ + connectors = ['dsn=%s' % (keys.pop('host', '') or \ keys.pop('dsn', ''))] else: port = '' @@ -73,7 +74,7 @@ connectors = ["DRIVER={%s}" % keys.pop('driver', self.pyodbc_driver_name), 'Server=%s%s' % (keys.pop('host', ''), port), - 'Database=%s' % keys.pop('database', '') ] + 'Database=%s' % keys.pop('database', '')] user = keys.pop("user", None) if user: @@ -90,8 +91,8 @@ connectors.append("AutoTranslate=%s" % |