Commit Graph

81 Commits

Author SHA1 Message Date
Jacob MacDonald e8a5ed9c1c Update usages of getargspec to compat version.
The places inspect.getargspec was being used were causing problems for
newer Python versions.
2015-10-29 12:09:15 -06:00
Mike Bayer 108c60f460 - The :class:.SessionEvents suite now includes events to allow
unambiguous tracking of all object lifecycle state transitions
in terms of the :class:`.Session` itself, e.g. pending,
transient,  persistent, detached.   The state of the object
within each event is also defined.
fixes #2677
- Added a new session lifecycle state :term:`deleted`.  This new state
represents an object that has been deleted from the :term:`persistent`
state and will move to the :term:`detached` state once the transaction
is committed.  This resolves the long-standing issue that objects
which were deleted existed in a gray area between persistent and
detached.   The :attr:`.InstanceState.persistent` accessor will
**no longer** report on a deleted object as persistent; the
:attr:`.InstanceState.deleted` accessor will instead be True for
these objects, until they become detached.
- The :paramref:`.Session.weak_identity_map` parameter is deprecated.
See the new recipe at :ref:`session_referencing_behavior` for
an event-based approach to maintaining strong identity map behavior.
references #3517
2015-09-02 17:55:15 -04:00
Mike Bayer 66fa5b50a5 - Fixed bug where the session attachment error "object is already
attached to session X" would fail to prevent the object from
also being attached to the new session, in the case that execution
continued after the error raise occurred.
fixes #3301
2015-03-10 17:51:35 -04:00
Mike Bayer cf7981f60d - 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
2014-12-12 19:59:11 -05:00
Mike Bayer 590498bf84 Merge branch 'master' into ticket_3100 2014-11-06 17:15:30 -05:00
Mike Bayer 38bc809841 - Fixed bug where :meth:.Session.expunge would not fully detach
the given object if the object had been subject to a delete
operation that was flushed, but not committed.  This would also
affect related operations like :func:`.make_transient`.
fixes #3139
2014-10-19 16:53:45 -04:00
Mike Bayer 6de1a87870 - Improvements to the mechanism used by :class:.Session to locate
"binds" (e.g. engines to use), such engines can be associated with
mixin classes, concrete subclasses, as well as a wider variety
of table metadata such as joined inheritance tables.
fixes #3035
2014-10-14 14:04:17 -04:00
Mike Bayer 1e5ffa029a - move BindTest into orm/test_binds 2014-10-14 12:07:38 -04:00
Mike Bayer 7e0c224162 Merge branch 'master' into ticket_3100 2014-09-02 15:05:32 -04:00
Mike Bayer 3c60d3b1ca - A new style of warning can be emitted which will "filter" up to
N occurrences of a parameterized string.   This allows parameterized
warnings that can refer to their arguments to be delivered a fixed
number of times until allowing Python warning filters to squelch them,
and prevents memory from growing unbounded within Python's
warning registries.
fixes #3178
2014-08-31 15:22:00 -04:00
Mike Bayer d006e9cc2a - skip these methods 2014-08-20 14:59:16 -04:00
Alex Gaynor 1caa7fafbd Fix many typos throughout the codebase
Found using: https://github.com/intgr/topy
2014-04-26 13:13:13 -07:00
Mike Bayer 9f74861d6d - Added new utility function :func:.make_transient_to_detached which can
be used to manufacture objects that behave as though they were loaded
from a session, then detached.   Attributes that aren't present
are marked as expired, and the object can be added to a Session
where it will act like a persistent one. fix #3017
2014-04-09 17:49:16 -04:00
Mike Bayer 50d19f55d2 - add some more rules to make sure all tests run if DBs are available 2014-03-24 12:49:22 -04:00
Mike Bayer 82a67abf4b - fix the uuid routine here to not run out of uuids 2014-03-24 11:57:38 -04:00
Mike Bayer 2f150bee28 - rename __multiple__ to __backend__, and apply __backend__ to a large number of tests.
- move out logging tests from test_execute to test_logging
2014-03-24 11:33:53 -04:00
Robin Schoonover f188e28aea Don't barf on Session(info=...) from sessionmaker(info=None) 2013-12-31 18:46:31 -07:00
Mike Bayer 08a6a8b519 - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor 2013-09-22 20:35:40 -04:00
Mike Bayer 4d132c38af 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`.
2013-08-02 12:39:29 -04:00
Mike Bayer 4b614b9b35 - the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
2013-04-27 19:53:57 -04:00
Mike Bayer 6c1972e4ec Improved the behavior of instance management regarding
the creation of strong references within the Session;
an object will no longer have an internal reference cycle
created if it's in the transient state or moves into the
detached state - the strong ref is created only when the
object is attached to a Session and is removed when the
object is detached.  This makes it somewhat safer for an
object to have a `__del__()` method, even though this is
not recommended, as relationships with backrefs produce
cycles too.  A warning has been added when a class with
a `__del__()` method is mapped.
[ticket:2708]
2013-04-20 02:45:08 -04:00
Mike Bayer 46b42b3bbd move this test to have its own data, avoid FK violations 2013-02-21 15:45:36 -05:00
Mike Bayer 26fb4b8163 - Added new helper function :func:.was_deleted, returns True
if the given object was the subject of a :meth:`.Session.delete`
operation.
- An object that's deleted from a session will be de-associated with
that session fully after the transaction is committed, that is
the :func:`.object_session` function will return None.
[ticket:2658]
2013-02-20 18:24:46 -05:00
Mike Bayer 6d1c473c47 - pep8 cleanup
- some global cleanup
2013-02-20 18:15:15 -05:00
Mike Bayer ab59e3e113 - [bug] Continuing [ticket:2566] regarding extra
state post-flush due to event listeners;
    any states that are marked as "dirty" from an
    attribute perspective, usually via column-attribute
    set events within after_insert(), after_update(),
    etc., will get the "history" flag reset
    in all cases, instead of only those instances
    that were part of the flush.  This has the effect
    that this "dirty" state doesn't carry over
    after the flush and won't result in UPDATE
    statements.   A warning is emitted to this
    effect; the set_committed_state()
    method can be used to assign attributes on objects
    without producing history events. [ticket:2582]
2012-10-06 12:46:02 -04:00
Mike Bayer b7b242dbb5 - break session tests into smaller suites. still some ambiguity what
some of these tests are testing
2012-10-06 12:10:01 -04:00
Mike Bayer 1c3e322552 - [feature] The Session will produce warnings
when unsupported methods are used inside the
    "execute" portion of the flush.   These are
    the familiar methods add(), delete(), etc.
    as well as collection and related-object
    manipulations, as called within mapper-level
    flush events
    like after_insert(), after_update(), etc.
    It's been prominently documented for a long
    time that  SQLAlchemy cannot guarantee
    results when the Session is manipulated within
    the execution of the flush plan,
    however users are still doing it, so now
    there's a warning.   Maybe someday the Session
    will be enhanced to support these operations
    inside of the flush, but for now, results
    can't be guaranteed.
2012-10-04 13:50:36 -04:00
Mike Bayer be40b51cb0 getting everything to pass again 2012-09-27 16:33:54 -04:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package.
in this system, we use kind of an ugly hack to get the noseplugin imported outside of the
"sqlalchemy" package, while still making it available within sqlalchemy for usage by
third party libraries.
2012-09-27 02:37:33 -04:00
Mike Bayer f72119a0ea - add a test to make sure we've tested session.execute(stmt, multiparams)
- rewrite docs for session.execute()
2012-09-09 00:54:45 -04:00
Mike Bayer df7a3792f5 - add req's for predictable gc 2012-09-05 12:46:28 -04:00
Mike Bayer 22ba1c43b7 -whitespace bonanza, contd 2012-07-28 17:05:50 -04:00
Mike Bayer b9406da13e remove deprecateds 2012-06-08 14:40:45 -04:00
Mike Bayer f5c98d5470 - [bug] The "passive" flag on Session.is_modified()
no longer has any effect. is_modified() in
all cases looks only at local in-memory
modified flags and will not emit any
SQL or invoke loader callables/initializers.
[ticket:2320]
2012-04-24 11:55:04 -04:00
Mike Bayer f7bb3b17e6 - the inspect interface is done, needs docs.
- start dressing up InstanceState for it's coming out, start moving
internal things to be underscored within the lib
2012-04-04 19:08:05 -04:00
Mike Bayer deb7e76a42 - [feature] Added "no_autoflush" context
manager to Session, used with with:
will temporarily disable autoflush.
2012-02-25 14:34:02 -05:00
Mike Bayer 81d5c82be6 move most tests that are specific to SessionTransaction over to test_transaction 2012-01-27 20:50:06 -05:00
Mike Bayer f9c2f85a3a - [bug] Fixed issue where modified session state
established after a failed flush would be committed
as part of the subsequent transaction that
begins automatically after manual call
to rollback().   The state of the session is
checked within rollback(), and if new state
is present, a warning is emitted and
restore_snapshot() is called a second time,
discarding those changes. [ticket:2389]

- repaired testing.assert_warnings to also verify
that any warnings were emitted
2012-01-27 20:32:52 -05:00
Mike Bayer cf41a6a041 -re-document the is_modified method, and place significant caveats
about the "passive" flag which is now known to be wrong.  Add
new is_modified tests illustrating the passive flag.
[ticket:2320]
2011-12-04 15:47:13 -05:00
Mike Bayer 212583b007 - When an open Session is garbage collected, the objects
within it which remain are considered detached again
when they are add()-ed to a new Session.
This is accomplished by an extra check that the previous
"session_key" doesn't actually exist among the pool
of Sessions.  [ticket:2281]
2011-09-24 11:12:34 -04:00
Mike Bayer 08f493dcb1 - Fixed bug where transaction-level "deleted"
collection wouldn't be cleared of expunged
states, raising an error if they later
became transient [ticket:2182].
Also in 0.6.8.
2011-06-05 12:22:34 -04:00
Mike Bayer 7b24e458c7 - move all the comments that got shoved below the fixture grabs back up 2011-03-27 17:19:00 -04:00
Mike Bayer 68a350d462 - remove test.sql._base, test.engine._base, test.orm._base, move those classes to a new test.lib.fixtures module
- move testing.TestBase to test.lib.fixtures
- massive search and replace
2011-03-27 16:27:27 -04:00
Mike Bayer a3083eabf4 - move all the setup_classes(cls) and setup_mappers(cls) to use a
local cls.Basic, cls.Comparable base class so that there is no ambiguity
or hash identity behaviors getting in the way of class registration.
2011-03-27 15:04:06 -04:00
Mike Bayer e3dbb87d94 - move _fixtures to work via the normal methods of _base.MappedTest, convert
all referncing tests to not use globals
- tests that deal with pickle specifically load the fixture classes
from test.lib.pickleable, which gets some more classes added
- removed weird sa05 pickling tests that don't matter
2011-03-26 20:44:47 -04:00
Mike Bayer 14a2fae239 - remove @testing.resolve_artifact_names, replace with direct attribute
access to the cls/self.tables/classes registries
- express orm/_base.py ORMTest in terms of engine/_base.py TablesTest,
factor out common steps into TablesTest, remove AltEngineTest as a
separate class.   will further consolidate these base classes
2011-03-26 19:03:11 -04:00
Mike Bayer b1b8e7defd - alex gaynor's latest batch of pypy test fixes 2011-03-16 13:04:07 -04:00
Mike Bayer b334fa458b - adjust gc_collect for pypy 2011-03-15 22:11:34 -04:00
Mike Bayer 403d786970 - some changes to the identity map regarding
rare weakref callbacks during iterations.
    The mutex has been removed as it apparently
    can cause a reentrant (i.e. in one thread) deadlock,
    perhaps when gc collects objects at the point of
    iteration in order to gain more memory.  It is hoped
    that "dictionary changed during iteration" will
    be exceedingly rare as iteration methods internally
    acquire the full list of objects in a single values()
    call. [ticket:2087]
2011-03-04 20:52:22 -05:00
Mike Bayer e43f85965e - The path given as the location of a sqlite database is now
normalized via os.path.abspath(), so that directory changes
within the process don't affect the ultimate location
of a relative file path.  [ticket:2036]
2011-02-10 15:03:11 -05:00