Commit Graph

57 Commits

Author SHA1 Message Date
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
Mike Bayer 8f381f202e - Adjusted flush accounting step to occur before
the commit in the case of autocommit=True.  This allows
autocommit=True to work appropriately with
expire_on_commit=True, and also allows post-flush session
hooks to operate in the same transactional context
as when autocommit=False.  [ticket:2041]
2011-02-07 16:12:24 -05:00
Mike Bayer ae5b58d9a5 - Session constructor emits a warning when autoflush=True
or expire_on_commit=True when autocommit=True.
[ticket:2041]
2011-02-07 13:30:27 -05:00
Mike Bayer a43b106aa7 - Session weak_instance_dict=False is deprecated.
[ticket:1473]
2011-02-05 16:48:17 -05:00
Mike Bayer 4a357af1ae - Session.connection(), Session.execute() accept 'bind',
to allow execute/connection operations to participate
in the open transaction of an engine explicitly.
[ticket:1996]
- fix up the docs for connection, execute, which were awful.
- correct usage strings in hybrid
2011-01-18 17:13:36 -05:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer d9b032e36a - move session/mapper events/extension tests into orm/test_events.py 2010-12-31 11:02:56 -05:00
Mike Bayer 426c4356eb - removes the "on_" prefix. 2010-12-30 14:22:43 -05:00
Mike Bayer 7f7bccfc83 - they don't want "on_". First step, change the naming convention on Events
so that non-events are just _name.
2010-12-30 13:43:39 -05:00
Mike Bayer d30678d18d new calling style: event.listen(target, identifier, fn) 2010-12-01 14:10:11 -05:00
Mike Bayer 69ee83d1cb - fix bug preventing multiple SessionExtensions from being correctly converted to event listeners 2010-11-28 16:43:30 -05:00
Mike Bayer 58b2939433 - sqlalchemy.test and nose plugin moves back to being entirely
outside of "sqlalchemy" and under "test/".

Rationale:

- coverage plugin works without issue, without need for an awkward
additional package install
- command line for "nosetests" isn't polluted with SQLAlchemy options

[ticket:1949]
2010-11-28 14:19:44 -05:00
Mike Bayer 99859369d1 - merge no-save-cascade collection flushes branch, [ticket:1973] 2010-11-20 15:11:12 -05:00
Mike Bayer 1321a0c2b9 - establish a consistent pattern of behavior along o2m, m2m, and m2o relationships
when "save-update" cascade is disabled, or the target object is otherwise not
present in the session, and collection/scalar changes have taken place.  A warning
is emitted describing the type of operation, the target reference, and the relationship
description, stating that the operation will not take place.  The operation then doesn't
take place.   [ticket:1973]
- clean up test_cascade a little bit, remove cruft
2010-11-17 19:34:47 -05:00
Mike Bayer e1402efb19 - move sqlalchemy.test to test.lib 2010-11-15 19:37:50 -05:00
Mike Bayer 4ac3240679 - SessionEvents is on board and the event model is done, can start building 0.7 tip soon 2010-11-14 17:51:54 -05:00
Mike Bayer 52735e75c5 - fix test_single test to use default dialect
- The exception raised by Session when it is used
subsequent to a subtransaction rollback (which is what
happens when a flush fails in autocommit=False mode) has
now been reworded (this is the "inactive due to a
rollback in a subtransaction" message). In particular,
if the rollback was due to an exception during flush(),
the message states this is the case, and reiterates the
string form of the original exception that occurred
during flush. If the session is closed due to explicit
usage of subtransactions (not very common), the message
just states this is the case.

- The exception raised by Mapper when repeated requests to
its initialization are made after initialization already
failed no longer assumes the "hasattr" case, since
there's other scenarios in which this message gets
emitted, and the message also does not compound onto
itself multiple times - you get the same message for
each attempt at usage. The misnomer "compiles" is being
traded out for "initialize".
2010-09-15 22:20:01 -04:00
Mike Bayer 177fdcb982 - Added a mutex to the identity map which mutexes
remove operations against iteration methods,
which now pre-buffer before returning an
iterable.   This because asyncrhonous gc
can remove items via the gc thread at any time.
[ticket:1891]
2010-09-07 12:16:29 -04:00
Mike Bayer af9fd453c0 - An object that's been deleted now gets a flag
'deleted', which prohibits the object from
being re-add()ed to the session, as previously
the object would live in the identity map
silently until its attributes were accessed.
The make_transient() function now resets this
flag along with the "key" flag.

- make_transient() can be safely called on an
already transient instance.
2010-08-26 11:32:50 -04:00
Mike Bayer 61562e5843 - object_session() raises the proper
UnmappedInstanceError when presented with an
unmapped instance.  [ticket:1881]
2010-08-18 10:54:40 -04:00
Mike Bayer 5cce6bf2a8 - experimenting with pytidy with mods as a textmate plugin along
the path to 78 chars.   eh
2010-07-10 14:50:13 -04:00
Mike Bayer 005d045350 - An instance which is moved to "transient", has
an incomplete or missing set of primary key
attributes, and contains expired attributes, will
raise an InvalidRequestError if an expired attribute
is accessed, instead of getting a recursion overflow.

- make_transient() removes all "loader" callables from
the state being made transient, removing any
"expired" state - all unloaded attributes reset back
to undefined, None/empty on access.
2010-06-30 16:12:32 -04:00
Mike Bayer 1675811029 - To accomodate the fact that there are now two kinds of eager
loading available, the new names for eagerload() and
eagerload_all() are joinedload() and joinedload_all().  The
old names will remain as synonyms for the foreseeable future.

- The "lazy" flag on the relationship() function now accepts
a string argument for all kinds of loading: "select", "joined",
"subquery", "noload" and "dynamic", where the default is now
"select".  The old values of True/
False/None still retain their usual meanings and will remain
as synonyms for the foreseeable future.

- Added documentation to tutorial,mapper doc, api docs
for subqueryload, subqueryload_all, and other options.
2010-03-24 19:11:01 -04:00
Mike Bayer 065fcbd9d2 - The official name for the relation() function is now
relationship(), to eliminate confusion over the relational
algebra term.  relation() however will remain available
in equal capacity for the foreseeable future.  [ticket:1740]
2010-03-17 17:48:29 -04:00
Mike Bayer d39a157489 - Session.execute() now locates table- and
mapper-specific binds based on a passed
in expression which is an insert()/update()/delete()
construct. [ticket:1054]
2009-12-08 03:09:18 +00:00