[Sqlalchemy-commits] sqlalchemy: - remove all compat items that are pre-2.5 (hooray)
Brought to you by:
zzzeek
From: <co...@sq...> - 2013-03-09 22:42:33
|
details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/41e7bc1cb87e changeset: 9221:41e7bc1cb87e user: Mike Bayer <mi...@zz...> date: Sat Mar 09 17:26:16 2013 -0500 description: - remove all compat items that are pre-2.5 (hooray) - other cleanup - don't need compat.decimal, that approach never panned out. hopefully outside libs aren't pulling it in, they shouldn't be Subject: sqlalchemy: merge default details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/5900bab529cb changeset: 9222:5900bab529cb user: Mike Bayer <mi...@zz...> date: Sat Mar 09 17:26:28 2013 -0500 description: merge default Subject: sqlalchemy: Added support for Postgresql's traditional SUBSTRING details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/8df5c7428a9c changeset: 9223:8df5c7428a9c user: Mike Bayer <mi...@zz...> date: Sat Mar 09 17:40:06 2013 -0500 description: Added support for Postgresql's traditional SUBSTRING function syntax, renders as "SUBSTRING(x FROM y FOR z)" when regular ``func.substring()`` is used. Also in 0.7.11. Courtesy Gunnlaugur Por Briem. [ticket:2676] Subject: sqlalchemy: Added support for Postgresql's traditional SUBSTRING details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/5f69112080fb changeset: 9224:5f69112080fb user: Mike Bayer <mi...@zz...> date: Sat Mar 09 17:41:32 2013 -0500 description: Added support for Postgresql's traditional SUBSTRING function syntax, renders as "SUBSTRING(x FROM y FOR z)" when regular ``func.substring()`` is used. Courtesy Gunnlaugur Por Briem. [ticket:2676] Subject: sqlalchemy: merge default details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/4f7b4267a6a9 changeset: 9225:4f7b4267a6a9 user: Mike Bayer <mi...@zz...> date: Sat Mar 09 17:41:46 2013 -0500 description: merge default diffstat: doc/build/changelog/changelog_07.rst | 9 + doc/build/changelog/changelog_08.rst | 9 + lib/sqlalchemy/dialects/firebird/kinterbasdb.py | 2 +- lib/sqlalchemy/dialects/mssql/pyodbc.py | 2 +- lib/sqlalchemy/dialects/oracle/cx_oracle.py | 2 +- lib/sqlalchemy/dialects/postgresql/base.py | 12 +- lib/sqlalchemy/dialects/postgresql/pg8000.py | 2 +- lib/sqlalchemy/dialects/postgresql/psycopg2.py | 2 +- lib/sqlalchemy/dialects/sybase/pyodbc.py | 2 +- lib/sqlalchemy/orm/mapper.py | 2 +- lib/sqlalchemy/pool.py | 4 +- lib/sqlalchemy/testing/profiling.py | 4 +- lib/sqlalchemy/testing/util.py | 3 +- lib/sqlalchemy/types.py | 7 +- lib/sqlalchemy/util/__init__.py | 16 +- lib/sqlalchemy/util/_collections.py | 39 ++---- lib/sqlalchemy/util/compat.py | 153 ------------------------ lib/sqlalchemy/util/langhelpers.py | 28 +++- lib/sqlalchemy/util/topological.py | 3 +- test/aaa_profiling/test_memusage.py | 2 +- test/dialect/test_mssql.py | 5 +- test/dialect/test_oracle.py | 5 +- test/dialect/test_postgresql.py | 13 +- test/orm/test_default_strategies.py | 1 - test/perf/stress_all.py | 2 +- test/sql/test_functions.py | 2 +- test/sql/test_types.py | 1 - 27 files changed, 110 insertions(+), 222 deletions(-) diffs (truncated from 717 to 300 lines): diff -r 761fc6a9f575 -r 4f7b4267a6a9 doc/build/changelog/changelog_07.rst --- a/doc/build/changelog/changelog_07.rst Sat Mar 09 14:42:34 2013 -0500 +++ b/doc/build/changelog/changelog_07.rst Sat Mar 09 17:41:46 2013 -0500 @@ -7,6 +7,15 @@ :version: 0.7.11 .. change:: + :tags: feature, postgresql + :tickets: 2676 + + Added support for Postgresql's traditional SUBSTRING + function syntax, renders as "SUBSTRING(x FROM y FOR z)" + when regular ``func.substring()`` is used. + Courtesy Gunnlaugur Ãór Briem. + + .. change:: :tags: bug, tests :tickets: 2669 :pullreq: 41 diff -r 761fc6a9f575 -r 4f7b4267a6a9 doc/build/changelog/changelog_08.rst --- a/doc/build/changelog/changelog_08.rst Sat Mar 09 14:42:34 2013 -0500 +++ b/doc/build/changelog/changelog_08.rst Sat Mar 09 17:41:46 2013 -0500 @@ -19,6 +19,15 @@ * :ref:`correlation_context_specific` .. change:: + :tags: feature, postgresql + :tickets: 2676 + + Added support for Postgresql's traditional SUBSTRING + function syntax, renders as "SUBSTRING(x FROM y FOR z)" + when regular ``func.substring()`` is used. + Also in 0.7.11. Courtesy Gunnlaugur Ãór Briem. + + .. change:: :tags: feature, orm :tickets: 2675 diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/firebird/kinterbasdb.py --- a/lib/sqlalchemy/dialects/firebird/kinterbasdb.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/firebird/kinterbasdb.py Sat Mar 09 17:41:46 2013 -0500 @@ -50,8 +50,8 @@ from .base import FBDialect, FBExecutionContext from ... import util, types as sqltypes -from ...util.compat import decimal from re import match +import decimal class _FBNumeric_kinterbasdb(sqltypes.Numeric): diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/mssql/pyodbc.py --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py Sat Mar 09 17:41:46 2013 -0500 @@ -114,7 +114,7 @@ from .base import MSExecutionContext, MSDialect from ...connectors.pyodbc import PyODBCConnector from ... import types as sqltypes, util -from ...util.compat import decimal +import decimal class _MSNumeric_pyodbc(sqltypes.Numeric): diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/oracle/cx_oracle.py --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py Sat Mar 09 17:41:46 2013 -0500 @@ -190,7 +190,7 @@ from sqlalchemy import types as sqltypes, util, exc, processors import random import collections -from sqlalchemy.util.compat import decimal +import decimal import re diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/postgresql/base.py --- a/lib/sqlalchemy/dialects/postgresql/base.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/postgresql/base.py Sat Mar 09 17:41:46 2013 -0500 @@ -1030,6 +1030,15 @@ field, self.process(expr)) + def visit_substring_func(self, func, **kw): + s = self.process(func.clauses.clauses[0], **kw) + start = self.process(func.clauses.clauses[1], **kw) + if len(func.clauses.clauses) > 2: + length = self.process(func.clauses.clauses[2], **kw) + return "SUBSTRING(%s FROM %s FOR %s)" % (s, start, length) + else: + return "SUBSTRING(%s FROM %s)" % (s, start) + class PGDDLCompiler(compiler.DDLCompiler): def get_column_specification(self, column, **kwargs): colspec = self.preparer.format_column(column) @@ -1042,8 +1051,7 @@ ( isinstance(column.default, schema.Sequence) and column.default.optional - ) - ): + )): if isinstance(impl_type, sqltypes.BigInteger): colspec += " BIGSERIAL" else: diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/postgresql/pg8000.py --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py Sat Mar 09 17:41:46 2013 -0500 @@ -27,7 +27,7 @@ """ from ... import util, exc -from ...util.compat import decimal +import decimal from ... import processors from ... import types as sqltypes from .base import PGDialect, \ diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/postgresql/psycopg2.py --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py Sat Mar 09 17:41:46 2013 -0500 @@ -147,7 +147,7 @@ import logging from ... import util, exc -from ...util.compat import decimal +import decimal from ... import processors from ...engine import result as _result from ...sql import expression diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/dialects/sybase/pyodbc.py --- a/lib/sqlalchemy/dialects/sybase/pyodbc.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/dialects/sybase/pyodbc.py Sat Mar 09 17:41:46 2013 -0500 @@ -36,7 +36,7 @@ SybaseExecutionContext from sqlalchemy.connectors.pyodbc import PyODBCConnector from sqlalchemy import types as sqltypes, processors -from sqlalchemy.util.compat import decimal +import decimal class _SybNumeric_pyodbc(sqltypes.Numeric): diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/orm/mapper.py --- a/lib/sqlalchemy/orm/mapper.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/orm/mapper.py Sat Mar 09 17:41:46 2013 -0500 @@ -2224,7 +2224,7 @@ state, state.dict, col, val) -class _ColumnMapping(util.py25_dict): +class _ColumnMapping(dict): """Error reporting helper for mapper._columntoproperty.""" def __init__(self, mapper): diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/pool.py --- a/lib/sqlalchemy/pool.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/pool.py Sat Mar 09 17:41:46 2013 -0500 @@ -736,8 +736,8 @@ self._overflow = 0 - pool_size self._max_overflow = max_overflow self._timeout = timeout - self._overflow_lock = self._max_overflow > -1 and \ - threading.Lock() or DummyLock() + self._overflow_lock = threading.Lock() if self._max_overflow > -1 \ + else DummyLock() def _do_return_conn(self, conn): try: diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/testing/profiling.py --- a/lib/sqlalchemy/testing/profiling.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/testing/profiling.py Sat Mar 09 17:41:46 2013 -0500 @@ -14,11 +14,12 @@ import time import collections from .. import util + try: import cProfile except ImportError: cProfile = None -from ..util.compat import jython, pypy, win32 +from ..util import jython, pypy, win32, update_wrapper _current_test = None @@ -210,7 +211,6 @@ profile_f.write("%s %s %s\n" % (test_key, platform_key, c)) profile_f.close() -from sqlalchemy.util.compat import update_wrapper def function_call_count(variance=0.05): diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/testing/util.py --- a/lib/sqlalchemy/testing/util.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/testing/util.py Sat Mar 09 17:41:46 2013 -0500 @@ -1,6 +1,5 @@ from ..util import jython, pypy, defaultdict, decorator -from ..util.compat import decimal - +import decimal import gc import time import random diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/types.py --- a/lib/sqlalchemy/types.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/types.py Sat Mar 09 17:41:46 2013 -0500 @@ -25,10 +25,10 @@ from . import exc, schema, util, processors, events, event from .sql import operators -from .sql.expression import _DefaultColumnComparator, column, bindparam +from .sql.expression import _DefaultColumnComparator from .util import pickle -from .util.compat import decimal from .sql.visitors import Visitable +import decimal default = util.importlater("sqlalchemy.engine", "default") NoneType = type(None) @@ -1372,8 +1372,7 @@ implementations however, most of which contain an import for plain ``decimal`` in their source code, even though some such as psycopg2 provide hooks for alternate adapters. SQLAlchemy imports ``decimal`` - globally as well. While the alternate ``Decimal`` class can be patched - into SQLA's ``decimal`` module, overall the most straightforward and + globally as well. The most straightforward and foolproof way to use "cdecimal" given current DBAPI and Python support is to patch it directly into sys.modules before anything else is imported:: diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/util/__init__.py --- a/lib/sqlalchemy/util/__init__.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/util/__init__.py Sat Mar 09 17:41:46 2013 -0500 @@ -4,10 +4,9 @@ # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -from .compat import callable, cmp, reduce, defaultdict, py25_dict, \ +from .compat import callable, cmp, reduce, \ threading, py3k, py3k_warning, jython, pypy, cpython, win32, set_types, \ - buffer, pickle, update_wrapper, partial, md5_hex, decode_slice, \ - dottedgetter, parse_qsl, any, contextmanager, namedtuple, next, WeakSet + pickle, dottedgetter, parse_qsl, namedtuple, next, WeakSet from ._collections import KeyedTuple, ImmutableContainer, immutabledict, \ Properties, OrderedProperties, ImmutableProperties, OrderedDict, \ @@ -21,8 +20,8 @@ portable_instancemethod, unbound_method_to_callable, \ getargspec_init, format_argspec_init, format_argspec_plus, \ get_func_kwargs, get_cls_kwargs, decorator, as_interface, \ - memoized_property, memoized_instancemethod, \ - group_expirable_memoized_property, importlater, \ + memoized_property, memoized_instancemethod, md5_hex, \ + group_expirable_memoized_property, importlater, decode_slice, \ monkeypatch_proxied_specials, asbool, bool_or_str, coerce_kw_type,\ duck_type_collection, assert_arg_type, symbol, dictlike_iteritems,\ classproperty, set_creation_order, warn_exception, warn, NoneType,\ @@ -31,3 +30,10 @@ from .deprecations import warn_deprecated, warn_pending_deprecation, \ deprecated, pending_deprecation + +# things that used to be not always available, +# but are now as of current support Python versions +from collections import defaultdict +from functools import partial +from functools import update_wrapper +from contextlib import contextmanager diff -r 761fc6a9f575 -r 4f7b4267a6a9 lib/sqlalchemy/util/_collections.py --- a/lib/sqlalchemy/util/_collections.py Sat Mar 09 14:42:34 2013 -0500 +++ b/lib/sqlalchemy/util/_collections.py Sat Mar 09 17:41:46 2013 -0500 @@ -6,7 +6,6 @@ """Collection classes and helpers.""" -import sys import itertools import weakref import operator @@ -649,37 +648,25 @@ self.add(o) -if sys.version_info >= (2, 5): - class PopulateDict(dict): - """A dict which populates missing values via a creation function. +class PopulateDict(dict): + """A dict which populates missing values via a creation function. - Note the creation function takes a key, unlike - collections.defaultdict. + Note the creation function takes a key, unlike + collections.defaultdict. - """ + """ - def __init__(self, creator): - self.creator = creator + def __init__(self, creator): + self.creator = creator |