Mike Bayer [Fri, 29 Aug 2014 19:07:11 +0000 (15:07 -0400)]
- reorganize how create_row_processor() communicates up to
instances(), using a named tuple it can assign to directly. this way
we never have to worry about that structure changing anymore, though
we are still having it append (key, fn) which is kind of awkward.
- inline _populators() into instance(), it's a little verbose but
saves an fn call
Mike Bayer [Fri, 29 Aug 2014 18:25:09 +0000 (14:25 -0400)]
- re-establish and test some behavior from previous versions, that
if a load() or refresh() event changes history (which...why...but anyway)
the state of the object is the same; currently it seems that history
gets reset but on a refresh, the object still goes into session.dirty
- simplify what we store in partials
Mike Bayer [Fri, 29 Aug 2014 18:01:38 +0000 (14:01 -0400)]
- The :class:`.Query` will raise an exception when :meth:`.Query.yield_per`
is used with mappings or options where eager loading, either
joined or subquery, would take place. These loading strategies are
not currently compatible with yield_per, so by raising this error,
the method is safer to use - combine with sending False to
:meth:`.Query.enable_eagerloads` to disable the eager loaders.
Mike Bayer [Fri, 29 Aug 2014 16:05:00 +0000 (12:05 -0400)]
- Changed the approach by which the "single inheritance criterion"
is applied, when using :meth:`.Query.from_self`, or its common
user :meth:`.Query.count`. The criteria to limit rows to those
with a certain type is now indicated on the inside subquery,
not the outside one, so that even if the "type" column is not
available in the columns clause, we can filter on it on the "inner"
query.
fixes #3177
Mike Bayer [Fri, 29 Aug 2014 00:06:12 +0000 (20:06 -0400)]
- major refactoring/inlining to loader.instances(), though not really
any speed improvements :(. code is in a much better place to be run into
C, however
- The ``proc()`` callable passed to the ``create_row_processor()``
method of custom :class:`.Bundle` classes now accepts only a single
"row" argument.
- Deprecated event hooks removed: ``populate_instance``,
``create_instance``, ``translate_row``, ``append_result``
- the getter() idea is somewhat restored; see ref #3175
Mike Bayer [Thu, 28 Aug 2014 21:57:48 +0000 (17:57 -0400)]
- Made a small adjustment to the mechanics of lazy loading,
such that it has less chance of interfering with a joinload() in the
very rare circumstance that an object points to itself; in this
scenario, the object refers to itself while loading its attributes
which can cause a mixup between loaders. The use case of
"object points to itself" is not fully supported, but the fix also
removes some overhead so for now is part of testing.
fixes #3145
Mike Bayer [Thu, 28 Aug 2014 16:25:21 +0000 (12:25 -0400)]
- A new implementation for :class:`.KeyedTuple` used by the
:class:`.Query` object offers dramatic speed improvements when
fetching large numbers of column-oriented rows.
fixes #3176
Mike Bayer [Tue, 26 Aug 2014 21:23:23 +0000 (17:23 -0400)]
- The behavior of :paramref:`.joinedload.innerjoin` as well as
:paramref:`.relationship.innerjoin` is now to use "nested"
inner joins, that is, right-nested, as the default behavior when an
inner join joined eager load is chained to an outer join eager load.
fixes #3008
Add note on begin_nested requiring rollback/commit
Avoid confusion about rollback/commit "must be issued" after
``session.begin_nested()`` --- this might be taken to mean call must be
*added*, but that's only true if not using the return value as a context
manager.
Mike Bayer [Thu, 21 Aug 2014 00:14:20 +0000 (20:14 -0400)]
- The INSERT...FROM SELECT construct now implies ``inline=True``
on :class:`.Insert`. This helps to fix a bug where an
INSERT...FROM SELECT construct would inadvertently be compiled
as "implicit returning" on supporting backends, which would
cause breakage in the case of an INSERT that inserts zero rows
(as implicit returning expects a row), as well as arbitrary
return data in the case of an INSERT that inserts multiple
rows (e.g. only the first row of many).
A similar change is also applied to an INSERT..VALUES
with multiple parameter sets; implicit RETURNING will no longer emit
for this statement either. As both of these constructs deal
with varible numbers of rows, the
:attr:`.ResultProxy.inserted_primary_key` accessor does not
apply. Previously, there was a documentation note that one
may prefer ``inline=True`` with INSERT..FROM SELECT as some databases
don't support returning and therefore can't do "implicit" returning,
but there's no reason an INSERT...FROM SELECT needs implicit returning
in any case. Regular explicit :meth:`.Insert.returning` should
be used to return variable numbers of result rows if inserted
data is needed.
fixes #3169
Mike Bayer [Wed, 20 Aug 2014 16:01:20 +0000 (12:01 -0400)]
- Fixed bug in connection pool logging where the "connection checked out"
debug logging message would not emit if the logging were set up using
``logging.setLevel()``, rather than using the ``echo_pool`` flag.
Tests to assert this logging have been added. This is a
regression that was introduced in 0.9.0.
fixes #3168
Mike Bayer [Mon, 18 Aug 2014 20:44:07 +0000 (16:44 -0400)]
- further reorganize collect_insert_commands to distinguish between
setting up given values vs. defaults. again trying to shoot for
making this of more general use
Mike Bayer [Mon, 18 Aug 2014 20:32:48 +0000 (16:32 -0400)]
- organize persistence methods in terms of generators,
narrow down argument lists and generator items for each function
down to just what each function needs. This will help for them
to be of more multipurpose use for bulk operations
Mike Bayer [Mon, 18 Aug 2014 16:50:29 +0000 (12:50 -0400)]
- major simplification of _collect_update_commands. in particular,
we only call upon the history API fully for primary key columns.
We also now skip the whole step of looking at PK columns and using
any history at all if no net changes are detected on the object.
Mike Bayer [Mon, 18 Aug 2014 00:06:16 +0000 (20:06 -0400)]
- Fixed bug where attribute "set" events or columns with
``@validates`` would have events triggered within the flush process,
when those columns were the targets of a "fetch and populate"
operation, such as an autoincremented primary key, a Python side
default, or a server-side default "eagerly" fetched via RETURNING.
fixes #3167
Mike Bayer [Fri, 15 Aug 2014 19:13:13 +0000 (15:13 -0400)]
- The :class:`.IdentityMap` exposed from :class:`.Session.identity`
now returns lists for ``items()`` and ``values()`` in Py3K.
Early porting to Py3K here had these returning iterators, when
they technically should be "iterable views"..for now, lists are OK.
Mike Bayer [Fri, 15 Aug 2014 18:57:29 +0000 (14:57 -0400)]
- TIL that dict.keys() in py3K is not an iterator, it is an iterable
view. So copy collections.OrderedDict and use MutableMapping to set up
keys, items, values on our own OrderedDict.
Mike Bayer [Fri, 15 Aug 2014 18:27:12 +0000 (14:27 -0400)]
- don't add the parent attach event within _on_table_attach
if we already have a table; this prevents reentrant calls and
we aren't supporting columns/etc being moved around between different parents
Mike Bayer [Fri, 15 Aug 2014 00:47:49 +0000 (20:47 -0400)]
- UPDATE statements can now be batched within an ORM flush
into more performant executemany() call, similarly to how INSERT
statements can be batched; this will be invoked within flush
to the degree that subsequent UPDATE statements for the
same mapping and table involve the identical columns within the
VALUES clause, as well as that no VALUES-level SQL expressions
are embedded.
- some other inlinings within persistence.py
Mike Bayer [Fri, 15 Aug 2014 00:00:35 +0000 (20:00 -0400)]
- The string keys that are used to determine the columns impacted
for an INSERT or UPDATE are now sorted when they contribute towards
the "compiled cache" cache key. These keys were previously not
deterministically ordered, meaning the same statement could be
cached multiple times on equivalent keys, costing both in terms of
memory as well as performance.
fixes #3165
Mike Bayer [Thu, 14 Aug 2014 18:40:28 +0000 (14:40 -0400)]
- Removing (or adding) an event listener at the same time that the event
is being run itself, either from inside the listener or from a
concurrent thread, now raises a RuntimeError, as the collection used is
now an instance of ``colletions.deque()`` and does not support changes
while being iterated. Previously, a plain Python list was used where
removal from inside the event itself would produce silent failures.
fixes #3163
Mike Bayer [Wed, 13 Aug 2014 23:45:34 +0000 (19:45 -0400)]
- The ``info`` parameter has been added to the constructor for
:class:`.SynonymProperty` and :class:`.ComparableProperty`.
- The ``info`` parameter has been added as a constructor argument
to all schema constructs including :class:`.MetaData`,
:class:`.Index`, :class:`.ForeignKey`, :class:`.ForeignKeyConstraint`,
:class:`.UniqueConstraint`, :class:`.PrimaryKeyConstraint`,
:class:`.CheckConstraint`.
Mike Bayer [Wed, 13 Aug 2014 23:20:44 +0000 (19:20 -0400)]
- The :meth:`.InspectionAttr.info` collection is now moved down to
:class:`.InspectionAttr`, where in addition to being available
on all :class:`.MapperProperty` objects, it is also now available
on hybrid properties, association proxies, when accessed via
:attr:`.Mapper.all_orm_descriptors`.
fixes #2971
Mike Bayer [Wed, 13 Aug 2014 21:42:33 +0000 (17:42 -0400)]
- public method name is get_enums()
- return a list of dicts like other methods do
- don't combine 'schema' with 'name', leave them separate
- support '*' argument so that we can retrieve cross-schema
if needed
- remove "conn" argument
- use bound parameters for 'schema' in SQL
- order by schema, name, label
- adapt _load_enums changes to column reflection
- changelog
- module docs for get_enums()
- add drop of enums to --dropfirst
Matt Chisholm [Sun, 27 Jul 2014 10:15:36 +0000 (12:15 +0200)]
fix MutableDict.coerce
If a class inherited from MutableDict (say, for instance, to add an update() method), coerce() would give back an instance of MutableDict instead of an instance of the derived class.
Mike Bayer [Thu, 7 Aug 2014 14:43:55 +0000 (10:43 -0400)]
-Fixed bug where Postgresql JSON type was not able to persist or
otherwise render a SQL NULL column value, rather than a JSON-encoded
``'null'``. To support this case, changes are as follows:
* The value :func:`.null` can now be specified, which will always
result in a NULL value resulting in the statement.
* A new parameter :paramref:`.JSON.none_as_null` is added, which
when True indicates that the Python ``None`` value should be
peristed as SQL NULL, rather than JSON-encoded ``'null'``.
Retrival of NULL as None is also repaired for DBAPIs other than
psycopg2, namely pg8000.