Mike Bayer [Sun, 25 Jan 2015 23:22:00 +0000 (18:22 -0500)]
- remove the clever approach w/ dialect events, and remove the need
for a for-loop through an empty tuple. we add one more local flag
to handle the logic without repetition of dialect.do_execute()
calls.
Mike Bayer [Sun, 25 Jan 2015 22:53:41 +0000 (17:53 -0500)]
- remove context-specific post-crud logic from Connection and inline post-crud
logic to some degree in DefaultExecutionContext. In particular
we are removing post_insert() which doesn't appear to be used
based on a survey of prominent third party dialects. Callcounts
aren't added to existing execute profiling tests and inserts might be
a little better.
- simplify the execution_options join in DEC. Callcounts don't
appear affected.
Mike Bayer [Tue, 20 Jan 2015 16:37:13 +0000 (11:37 -0500)]
- Added new user-space accessors for viewing transaction isolation
levels; :meth:`.Connection.get_isolation_level`,
:attr:`.Connection.default_isolation_level`.
- enhance documentation inter-linkage between new accessors,
existing isolation_level parameters, as well as in
the dialect-level methods which should be fully covered
by Engine/Connection level APIs now.
Mike Bayer [Mon, 19 Jan 2015 22:55:23 +0000 (17:55 -0500)]
- The primary :class:`.Mapper` of a :class:`.Query` is now passed to the
:meth:`.Session.get_bind` method when calling upon
:meth:`.Query.count`, :meth:`.Query.update`, :meth:`.Query.delete`,
as well as queries against mapped columns,
:obj:`.column_property` objects, and SQL functions and expressions
derived from mapped columns. This allows sessions that rely upon
either customized :meth:`.Session.get_bind` schemes or "bound" metadata
to work in all relevant cases.
fixes #3227 fixes #3242 fixes #1326
Mike Bayer [Sun, 18 Jan 2015 02:36:52 +0000 (21:36 -0500)]
- fix a regression from ref #3178, where dialects that don't actually support
sane multi rowcount (e.g. pyodbc) would fail on multirow update. add
a test that mocks this breakage into plain dialects
Mike Bayer [Sat, 17 Jan 2015 01:03:33 +0000 (20:03 -0500)]
- Custom dialects that implement :class:`.GenericTypeCompiler` can
now be constructed such that the visit methods receive an indication
of the owning expression object, if any. Any visit method that
accepts keyword arguments (e.g. ``**kw``) will in most cases
receive a keyword argument ``type_expression``, referring to the
expression object that the type is contained within. For columns
in DDL, the dialect's compiler class may need to alter its
``get_column_specification()`` method to support this as well.
The ``UserDefinedType.get_col_spec()`` method will also receive
``type_expression`` if it provides ``**kw`` in its argument
signature.
fixes #3074
Mike Bayer [Fri, 16 Jan 2015 23:03:45 +0000 (18:03 -0500)]
- Fixed bug where Postgresql dialect would fail to render an
expression in an :class:`.Index` that did not correspond directly
to a table-bound column; typically when a :func:`.text` construct
was one of the expressions within the index; or could misinterpret the
list of expressions if one or more of them were such an expression.
fixes #3174
Mike Bayer [Tue, 13 Jan 2015 22:04:35 +0000 (17:04 -0500)]
- The "wildcard" loader options, in particular the one set up by
the :func:`.orm.load_only` option to cover all attributes not
explicitly mentioned, now takes into account the superclasses
of a given entity, if that entity is mapped with inheritance mapping,
so that attribute names within the superclasses are also omitted
from the load. Additionally, the polymorphic discriminator column
is unconditionally included in the list, just in the same way that
primary key columns are, so that even with load_only() set up,
polymorphic loading of subtypes continues to function correctly.
fixes #3287
Mike Bayer [Tue, 13 Jan 2015 19:33:33 +0000 (14:33 -0500)]
- The multi-values version of :meth:`.Insert.values` has been
repaired to work more usefully with tables that have Python-
side default values and/or functions, as well as server-side
defaults. The feature will now work with a dialect that uses
"positional" parameters; a Python callable will also be
invoked individually for each row just as is the case with an
"executemany" style invocation; a server- side default column
will no longer implicitly receive the value explicitly
specified for the first row, instead refusing to invoke
without an explicit value. fixes #3288
Mike Bayer [Tue, 6 Jan 2015 02:38:19 +0000 (21:38 -0500)]
- Fixed bug where if an exception were thrown at the start of a
:class:`.Query` before it fetched results, particularly when
row processors can't be formed, the cursor would stay open with
results pending and not actually be closed. This is typically only
an issue on an interpreter like Pypy where the cursor isn't
immediately GC'ed, and can in some circumstances lead to transactions/
locks being open longer than is desirable.
fixes #3285
Mike Bayer [Tue, 6 Jan 2015 00:02:08 +0000 (19:02 -0500)]
- add MemoizedSlots, a generalized solution to using __getattr__
for memoization on a class that uses slots.
- apply many more __slots__. mem use for nova now at 46% savings
Mike Bayer [Mon, 5 Jan 2015 00:28:08 +0000 (19:28 -0500)]
- Structural memory use has been improved via much more significant use
of ``__slots__`` for many internal objects. This optimization is
particularly geared towards the base memory size of large applications
that have lots of tables and columns, and greatly reduces memory
size for a variety of high-volume objects including event listening
internals, comparator objects and parts of the ORM attribute and
loader strategy system.
Mike Bayer [Mon, 5 Jan 2015 00:05:31 +0000 (19:05 -0500)]
- scale back _Dispatch and _JoinedDispatcher to use a __getitem__ scheme
to start up listener collections; this pulls the overhead off of construction
and makes performance much like the descriptor version, while still allowing
slots. Fix up some profiles.
Mike Bayer [Sun, 4 Jan 2015 06:53:42 +0000 (01:53 -0500)]
- start trying to move things into __slots__. This seems to reduce the
size of the many per-column objects we're hitting, but somehow the overall memory is
hardly being reduced at all in initial testing
Mike Bayer [Sun, 4 Jan 2015 01:43:45 +0000 (20:43 -0500)]
- The :class:`.mysql.SET` type has been overhauled to no longer
assume that the empty string, or a set with a single empty string
value, is in fact a set with a single empty string; instead, this
is by default treated as the empty set. In order to handle persistence
of a :class:`.mysql.SET` that actually wants to include the blank
value ``''`` as a legitimate value, a new bitwise operational mode
is added which is enabled by the
:paramref:`.mysql.SET.retrieve_as_bitwise` flag, which will persist
and retrieve values unambiguously using their bitflag positioning.
Storage and retrieval of unicode values for driver configurations
that aren't converting unicode natively is also repaired.
fixes #3283
Mike Bayer [Thu, 1 Jan 2015 18:47:08 +0000 (13:47 -0500)]
- restate sort_tables in terms of a more fine grained
sort_tables_and_constraints function.
- The DDL generation system of :meth:`.MetaData.create_all`
and :meth:`.Metadata.drop_all` has been enhanced to in most
cases automatically handle the case of mutually dependent
foreign key constraints; the need for the
:paramref:`.ForeignKeyConstraint.use_alter` flag is greatly
reduced. The system also works for constraints which aren't given
a name up front; only in the case of DROP is a name required for
at least one of the constraints involved in the cycle.
fixes #3282
Mike Bayer [Thu, 1 Jan 2015 18:24:32 +0000 (13:24 -0500)]
- Added a new accessor :attr:`.Table.foreign_key_constraints`
to complement the :attr:`.Table.foreign_keys` collection,
as well as :attr:`.ForeignKeyConstraint.referred_table`.
Mike Bayer [Tue, 30 Dec 2014 01:01:21 +0000 (20:01 -0500)]
- fix some RST whitespace syntactical issues in toctrees
- have the topmost toctree only include page names
- add glossary to toctree, remove search by itself
Mike Bayer [Fri, 19 Dec 2014 17:14:52 +0000 (12:14 -0500)]
- Fixed bug where using a :class:`.TypeDecorator` that implemented
a type that was also a :class:`.TypeDecorator` would fail with
Python's "Cannot create a consistent method resolution order (MRO)"
error, when any kind of SQL comparison expression were used against
an object using this type.
Mike Bayer [Wed, 17 Dec 2014 22:24:23 +0000 (17:24 -0500)]
- squash-merge the improve_toc branch, which moves all the Sphinx styling
and extensions into an external library, and also reorganizes most large documentation
pages into many small areas to reduce scrolling and better present the context
into a more fine-grained hierarchy.
Mike Bayer [Sat, 13 Dec 2014 23:04:11 +0000 (18:04 -0500)]
- rework sqlite FK and unique constraint system to combine both PRAGMA
and regexp parsing of SQL in order to form a complete picture of
constraints + their names. fixes #3244 fixes #3261
- factor various PRAGMA work to be centralized into one call
Mike Bayer [Sat, 13 Dec 2014 00:59:11 +0000 (19:59 -0500)]
- Added new method :meth:`.Session.invalidate`, functions similarly
to :meth:`.Session.close`, except also calls
:meth:`.Connection.invalidate`
on all connections, guaranteeing that they will not be returned to
the connection pool. This is useful in situations e.g. dealing
with gevent timeouts when it is not safe to use the connection further,
even for rollbacks.
references #3258
Mike Bayer [Mon, 8 Dec 2014 20:15:02 +0000 (15:15 -0500)]
- identify another spot where _handle_dbapi_error() needs to do something
differently for the case where it is called in an already-invalidated state;
don't call upon self.connection
Mike Bayer [Mon, 8 Dec 2014 19:05:20 +0000 (14:05 -0500)]
- simplify the "noconnection" error handling, setting
_handle_dbapi_exception_noconnection() to only invoke in the case
of raw_connection() in the constructor of Connection. in all other
cases the Connection proceeds with _handle_dbapi_exception() including
revalidate.
Mike Bayer [Mon, 8 Dec 2014 06:10:30 +0000 (01:10 -0500)]
- A new series of :class:`.Session` methods which provide hooks
directly into the unit of work's facility for emitting INSERT
and UPDATE statements has been created. When used correctly,
this expert-oriented system can allow ORM-mappings to be used
to generate bulk insert and update statements batched into
executemany groups, allowing the statements to proceed at
speeds that rival direct use of the Core.
fixes #3100
Mike Bayer [Sun, 7 Dec 2014 23:54:52 +0000 (18:54 -0500)]
- rework the assert_sql system so that we have a context manager to work with,
use events that are local to the engine and to the run and are removed afterwards.
Mike Bayer [Sat, 6 Dec 2014 18:30:51 +0000 (13:30 -0500)]
- SQL Server 2012 now recommends VARCHAR(max), NVARCHAR(max),
VARBINARY(max) for large text/binary types. The MSSQL dialect will
now respect this based on version detection, as well as the new
``deprecate_large_types`` flag.
fixes #3039
Mike Bayer [Sat, 6 Dec 2014 00:08:47 +0000 (19:08 -0500)]
- adjust _revalidate_connection() again such that we pass a _wrap=False
to it, so that we say we will do the wrapping just once right here
in _execute_context() / _execute_default(). An adjustment is made
to _handle_dbapi_error() to not assume self.__connection in case
we are already in an invalidated state