Mike Bayer [Wed, 7 Aug 2013 18:28:45 +0000 (13:28 -0500)]
- The :meth:`.Operators.notin_` operator added in 0.8 now properly
produces the negation of the expression "IN" returns
when used against an empty collection. Also in 0.8.3.
Mike Bayer [Fri, 2 Aug 2013 22:21:02 +0000 (18:21 -0400)]
- after discussions with the original project folks working with zope security
proxies, they aren't overriding getattr() or setattr() at all. so all the
hardcoded getattr()/setattr() is removed from collections.py. Lots of these
getattr/setattr were against the attributeimpl and decorated functions
and don't seem like they'd ever be needed; for a user that needs special access
to a collection, we can evaulate that use case and add a single point of
"unwrapping", and probably add a hook for it via
InstrumentationManager so that the collection implementation isn't complicated
by it.
Mike Bayer [Fri, 2 Aug 2013 17:27:30 +0000 (13:27 -0400)]
a missing cursor.close() here caused a *huge* amount of weird locking issues with pypy,
what is strange is how it only occurred in some very specific places under very
particular conditions, perhaps it has to do with whether or not this cursor gets
gc'ed or not.
Mike Bayer [Fri, 2 Aug 2013 16:39:29 +0000 (12:39 -0400)]
Added a new attribute :attr:`.Session.info` to :class:`.Session`;
this is a dictionary where applications can store arbitrary
data local to a :class:`.Session`.
The contents of :attr:`.Session.info` can be also be initialized
using the ``info`` argument of :class:`.Session` or
:class:`.sessionmaker`.
Mike Bayer [Fri, 2 Aug 2013 00:25:56 +0000 (20:25 -0400)]
- assorted fixes raised by pypy 2.1beta2, but all of which are good
ideas in general:
- pypy2.1 w/ sqlite3 is the first DBAPI we're seeing returning
unicode in cursor.description without being py3k. add a new on-connect
check for this, if we get back a u"", just don't do description decoding,
should be OK for now.
- the set tests in test_collection were assuming the two sets would be ordered
the same when it tested pop(), can't really assume that.
- test_serializer gets worse and worse, pickle is just not really viable here,
ding out pypy
- pypy2.1b2 seems to allow cursor.lastrowid to work (or we changed something?)
- pool._threadconns.current() is a weakref, it can be None
- another one of those logging.handlers imports
Mike Bayer [Wed, 31 Jul 2013 22:42:58 +0000 (18:42 -0400)]
- Fixed bug in common table expression system where if the CTE were
used only as an ``alias()`` construct, it would not render using the
WITH keyword. Also in 0.8.3, 0.7.11.
[ticket:2783]
Mike Bayer [Sat, 27 Jul 2013 21:05:01 +0000 (17:05 -0400)]
- fix issue in join rewriting whereby we need to ensure the .key and .name
are transferred correctly for when .key is present; tests have been enhanced
to test this condition for render, result map construction, statement
execution. [ticket:2790]
Mike Bayer [Fri, 26 Jul 2013 23:11:33 +0000 (19:11 -0400)]
- add event.contains() function to the event package, returns True
if the given target/event/fn is set up to listen.
- repair mutable package which is doing some conditional event listening
Mike Bayer [Fri, 26 Jul 2013 18:21:58 +0000 (14:21 -0400)]
- Removal of event listeners is now implemented. The feature is
provided via the :func:`.event.remove` function.
[ticket:2268]
- reorganization of event.py module into a package; with the addition of the
docstring work as well as the new registry for removal, there's a lot more code now.
the package separates concerns and provides a top-level doc for each subsection
of functionality
- the remove feature works by providing the EventKey object which associates
the user-provided arguments to listen() with a global, weak-referencing registry.
This registry stores a collection of _ListenerCollection and _DispatchDescriptor
objects associated with each set of arguments, as well as the wrapped function
which was applied to that collection. The EventKey can then be recreated for
a removal, all the _ListenerCollection and _DispatchDescriptor objects are located,
and the correct wrapped function is removed from each one.
Mike Bayer [Fri, 26 Jul 2013 04:01:04 +0000 (00:01 -0400)]
- The mechanism by which attribute events pass along an
:class:`.AttributeImpl` as an "initiator" token has been changed;
the object is now an event-specific object called :class:`.attributes.Event`.
Additionally, the attribute system no longer halts events based
on a matching "initiator" token; this logic has been moved to be
specific to ORM backref event handlers, which are the typical source
of the re-propagation of an attribute event onto subsequent append/set/remove
operations. End user code which emulates the behavior of backrefs
must now ensure that recursive event propagation schemes are halted,
if the scheme does not use the backref handlers. Using this new system,
backref handlers can now peform a
"two-hop" operation when an object is appended to a collection,
associated with a new many-to-one, de-associated with the previous
many-to-one, and then removed from a previous collection. Before this
change, the last step of removal from the previous collection would
not occur.
[ticket:2789]
Mike Bayer [Sat, 20 Jul 2013 02:56:34 +0000 (22:56 -0400)]
- Improved the examples in ``examples/generic_associations``, including
that ``discriminator_on_association.py`` makes use of single table
inheritance do the work with the "discriminator". Also
added a true "generic foreign key" example, which works similarly
to other popular frameworks in that it uses an open-ended integer
to point to any other table, foregoing traditional referential
integrity. While we don't recommend this pattern, information wants
to be free. Also in 0.8.3.
- Added a convenience class decorator :func:`.as_declarative`, is
a wrapper for :func:`.declarative_base` which allows an existing base
class to be applied using a nifty class-decorated approach. Also
in 0.8.3.
Mike Bayer [Fri, 19 Jul 2013 03:17:33 +0000 (23:17 -0400)]
Fixed bug in ORM-level event registration where the "raw" or
"propagate" flags could potentially be mis-configured in some
"unmapped base class" configurations. Also in 0.8.3.
[ticket:2786]
Mike Bayer [Wed, 17 Jul 2013 15:18:59 +0000 (11:18 -0400)]
Fixed bug in :class:`.CheckConstraint` DDL where the "quote" flag from a
:class:`.Column` object would not be propagated. Also in 0.8.3, 0.7.11.
[ticket:2784]
Mike Bayer [Sat, 13 Jul 2013 20:28:42 +0000 (16:28 -0400)]
A performance fix related to the usage of the :func:`.defer` option
when loading mapped entities. The function overhead of applying
a per-object deferred callable to an instance at load time was
significantly higher than that of just loading the data from the row
(note that ``defer()`` is meant to reduce DB/network overhead, not
necessarily function call count); the function call overhead is now
less than that of loading data from the column in all cases. There
is also a reduction in the number of "lazy callable" objects created
per load from N (total deferred values in the result) to 1 (total
number of deferred cols).
[ticket:2778]
Mike Bayer [Sat, 13 Jul 2013 01:52:54 +0000 (21:52 -0400)]
The newly added SQLite DATETIME arguments storage_format and
regexp apparently were not fully implemented correctly; while the
arguments were accepted, in practice they would have no effect;
this has been fixed. Also in 0.8.3.
[ticket:2781]
Mike Bayer [Fri, 12 Jul 2013 15:32:34 +0000 (11:32 -0400)]
Fixed bug where the expression system relied upon the ``str()``
form of a some expressions when referring to the ``.c`` collection
on a ``select()`` construct, but the ``str()`` form isn't available
since the element relies on dialect-specific compilation constructs,
notably the ``__getitem__()`` operator as used with a Postgresql
``ARRAY`` element. The fix also adds a new exception class
:class:`.UnsupportedCompilationError` which is raised in those cases
where a compiler is asked to compile something it doesn't know
how to. Also in 0.8.3.
[ticket:2780]
Mike Bayer [Thu, 11 Jul 2013 19:15:09 +0000 (15:15 -0400)]
Dialect.initialize() is not called a second time if an :class:`.Engine`
is recreated, due to a disconnect error. This fixes a particular
issue in the Oracle 8 dialect, but in general the dialect.initialize()
phase should only be once per dialect. Also in 0.8.3. [ticket:2776]
Mike Bayer [Tue, 9 Jul 2013 15:52:31 +0000 (11:52 -0400)]
- we dont actually need this unicode cast, on py3k + linux it seems the
has_table issues are OK. On OSX forget it.
- still some issues with PY3k + pyodbc + decimal values it doesn't expect, not sure
Mike Bayer [Mon, 8 Jul 2013 17:39:56 +0000 (13:39 -0400)]
- create a new system where we can decorate an event method
with @_legacy_signature, will inspect incoming listener functions
to see if they match an older signature, will wrap into a newer sig
- add an event listen argument named=True, will send all args as
kw args so that event listeners can be written with **kw, any combination
of names
- add a doc system to events that writes out the various calling styles
for a given event, produces deprecation messages automatically.
a little concerned that it's a bit verbose but will look at it up
on RTD for awhile to get a feel.
- change the calling signature for bulk update/delete events - we have
the BulkUD object right there, and there's at least six or seven things
people might want to see, so just send the whole BulkUD in
[ticket:2775]
Mike Bayer [Fri, 5 Jul 2013 19:51:24 +0000 (15:51 -0400)]
- Added new method to the :func:`.insert` construct
:meth:`.Insert.from_select`. Given a list of columns and
a selectable, renders ``INSERT INTO (table) (columns) SELECT ..``.
While this feature is highlighted as part of 0.9 it is also
backported to 0.8.3. [ticket:722]
- The :func:`.update`, :func:`.insert`, and :func:`.delete` constructs
will now interpret ORM entities as FROM clauses to be operated upon,
in the same way that select() already does. Also in 0.8.3.
Mike Bayer [Fri, 5 Jul 2013 00:01:55 +0000 (20:01 -0400)]
Fixed bug whereby attribute history functions would fail
when an object we moved from "persistent" to "pending"
using the :func:`.make_transient` function, for operations
involving collection-based backrefs.
[ticket:2773]
Mike Bayer [Thu, 4 Jul 2013 17:18:00 +0000 (13:18 -0400)]
Fixed bug where :class:`.QueuePool` would lose the correct
checked out count if an existing pooled connection failed to reconnect
after an invalidate or recycle event. Also in 0.8.3.
[ticket:2772]
Mike Bayer [Wed, 3 Jul 2013 00:35:01 +0000 (20:35 -0400)]
for this test, apparently we don't handle sets as unordered since neither does
MySQL. for some reason set ordering was constant when testing mysqldb, but not
so with oursql.
Mike Bayer [Tue, 2 Jul 2013 22:24:58 +0000 (18:24 -0400)]
Fixed bug when using multi-table UPDATE where a supplemental
table is a SELECT with its own bound parameters, where the positioning
of the bound parameters would be reversed versus the statement
itself when using MySQL's special syntax.
[ticket:2768]
Mike Bayer [Tue, 2 Jul 2013 22:02:20 +0000 (18:02 -0400)]
ORM descriptors such as hybrid properties can now be referenced
by name in a string argument used with ``order_by``,
``primaryjoin``, or similar in :func:`.relationship`,
in addition to column-bound attributes. [ticket:2761]
Mike Bayer [Tue, 2 Jul 2013 17:14:21 +0000 (13:14 -0400)]
- refactor pool a bit so that intent between ConnectionRecord/ConnectionFairy is clear;
make sure that the DBAPI connection passed to the reset-on-return events/dialect hooks
is also a "fairy", so that dictionaries like "info" are available. [ticket:2770]
- rework the execution_options system so that the dialect is given the job of making
any immediate adjustments based on a set event. move the "isolation level" logic to use
this new system. Also work things out so that even engine-level execution options
can be used for things like isolation level; the dialect attaches a connect-event
handler in this case to handle the task.
- to support this new system as well as further extensibiltiy of execution options
add events engine_connect(), set_connection_execution_options(), set_engine_execution_options()
Mike Bayer [Sun, 30 Jun 2013 23:48:48 +0000 (19:48 -0400)]
Added new flag ``retaining=False`` to the kinterbasdb and fdb dialects.
This controls the value of the ``retaining`` flag sent to the
``commit()`` and ``rollback()`` methods of the DBAPI connection.
Defaults to False. Also in 0.8.2, where it defaults to True.
[ticket:2763]
Mike Bayer [Sun, 30 Jun 2013 22:35:12 +0000 (18:35 -0400)]
- replace most explicitly-named test objects called "Mock..." with
actual mock objects from the mock library. I'd like to use mock
for new tests so we might as well use it in obvious places.
- use unittest.mock in py3.3
- changelog
- add a note to README.unittests
- add tests_require in setup.py
- have tests import from sqlalchemy.testing.mock
- apply usage of mock to one of the event tests. we can be using
this approach all over the place.
Mike Bayer [Sun, 30 Jun 2013 15:09:37 +0000 (11:09 -0400)]
A warning is emitted when trying to flush an object of an inherited
mapped class where the polymorphic discriminator has been assigned
to a value that is invalid for the class. [ticket:2750]
Mike Bayer [Sat, 29 Jun 2013 03:53:27 +0000 (23:53 -0400)]
The behavior of :func:`.extract` has been simplified on the
Postgresql dialect to no longer inject a hardcoded ``::timestamp``
or similar cast into the given expression, as this interfered
with types such as timezone-aware datetimes, but also
does not appear to be at all necessary with modern versions
of psycopg2. Also in 0.8.2.
[ticket:2740]
Mike Bayer [Fri, 28 Jun 2013 15:49:41 +0000 (11:49 -0400)]
Type lookup when reflecting the Firebird types LONG and
INT64 has been fixed so that LONG is treated as INTEGER,
INT64 treated as BIGINT, unless the type has a "precision"
in which case it's treated as NUMERIC. Patch courtesy
Russell Stuart.
[ticket:2757]
Mike Bayer [Fri, 28 Jun 2013 15:35:57 +0000 (11:35 -0400)]
Fixed bug in HSTORE type where keys/values that contained
backslashed quotes would not be escaped correctly when
using the "non native" (i.e. non-psycopg2) means
of translating HSTORE data. Patch courtesy Ryan Kelly.
[ticket:2766]
Mike Bayer [Thu, 27 Jun 2013 20:43:01 +0000 (16:43 -0400)]
- fix a regression caused by #2587, where query.join() would apply an
adapter to an aliased-mapped, non-polymorphic selectable that prevented us from referring
directly to that selectable.
Mike Bayer [Tue, 25 Jun 2013 21:32:51 +0000 (17:32 -0400)]
- rework of correlation, continuing on #2668, #2746
- add support for correlations to propagate all the way in; because
correlations require context now, need to make sure a select enclosure
of any level takes effect any number of levels deep.
- fix what we said correlate_except() was supposed to do when we first
released #2668 - "the FROM clause is left intact if the correlated SELECT
is not used in the context of an enclosing SELECT..." - it was not
considering the "existing_froms" collection at all, and prohibited
additional FROMs from being placed in an any() or has().
- add test for multilevel any()
- lots of docs, including glossary entries as we really need to define
"WHERE clause", "columns clause" etc. so that we can explain correlation better
- based on the insight that a SELECT can correlate anything that ultimately
came from an enclosing SELECT that links to this one via WHERE/columns/HAVING/ORDER BY,
have the compiler keep track of the FROM lists that correspond in this way,
link it to the asfrom flag, so that we send to _get_display_froms() the exact
list of candidate FROMs to correlate. no longer need any asfrom logic in the
Select() itself
- preserve 0.8.1's behavior for correlation when no correlate options are given, not
to mention 0.7 and prior's behavior of not propagating implicit correlation more than one level..
this is to reduce surprises/hard-to-debug situations when a user isn't trying
to correlate anything.