Commit Graph

42 Commits

Author SHA1 Message Date
Mike Bayer 0be865d7bd Add tests for ARRAY propagate events re. MutableList
Issue #4141 appears in version 1.2, however we are adding the
MutableList test for it to 1.1 as well.  The metadata test
does not apply as in 1.1 ARRAY is not a SchemaEventTarget.

Change-Id: If8c57615860883837f6cf72661e46180a77778c1
(cherry picked from commit 14bb6eae364f41b6acbce782ebf5f984b9364af9)
2017-12-04 17:42:04 -05:00
Mike Bayer 1ad5ad165d Ensure we check that SQL expression has an .info attribute
Fixed regression released in 1.1.8 due to 🎫`3950` where the
deeper search for information about column types in the case of a
"schema type" or a :class:`.TypeDecorator` would produce an attribute
error if the mapping also contained a :obj:`.column_property`.

Change-Id: I38254834d3d79c9b339289a8163eb4789ec4c931
Fixes: #3956
(cherry picked from commit d13734add3)
2017-04-04 09:07:14 -04:00
Mike Bayer 502a46b64e Track SchemaEventTarget types in as_mutable()
Fixed bug in :mod:`sqlalchemy.ext.mutable` where the
:meth:`.Mutable.as_mutable` method would not track a type that had
been copied using :meth:`.TypeEngine.copy`.  This became more of
a regression in 1.1 compared to 1.0 because the :class:`.TypeDecorator`
class is now a subclass of :class:`.SchemaEventTarget`, which among
other things indicates to the parent :class:`.Column` that the type
should be copied when the :class:`.Column` is.  These copies are
common when using declarative with mixins or abstract classes.

Change-Id: Ib04df862c58263185dbae686c548fea3e12c46f1
Fixes: #3950
(cherry picked from commit 07b63894cb)
2017-03-30 17:52:56 -04:00
Khairi Hafsham 772374735d Make all tests to be PEP8 compliant
tested using pycodestyle version 2.2.0

Fixes: #3885
Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
2017-02-07 11:21:56 -05:00
Jeong YunWon f7354b43e4 Add sqlalchemy.ext.mutable.MutableSet
from https://bitbucket.org/zzzeek/sqlalchemy/issues/3297
2016-02-13 21:28:50 +09:00
Jeong YunWon 1b6422a603 Add sqlalchemy.ext.mutable.MutableList 2016-02-13 21:28:46 +09:00
Mike Bayer 913858c949 - Further fixes to 🎫3605, pop method on :class:.MutableDict,
where the "default" argument was not included.
fixes #3605
2015-12-17 11:24:35 -05:00
Mike Bayer 5710a1e88b - Added support for the `dict.pop() and dict.popitem()` methods
to the :class:`.mutable.MutableDict` class.
fixes #3605
2015-12-11 11:21:46 -05:00
Mike Bayer 525cc6fe02 - Fixed regression in the :mod:sqlalchemy.ext.mutable extension
as a result of the bugfix for 🎫`3167`,
where attribute and validation events are no longer
called within the flush process.  The mutable
extension was relying upon this behavior in the case where a column
level Python-side default were responsible for generating the new value
on INSERT or UPDATE, or when a value were fetched from the RETURNING
clause for "eager defaults" mode.  The new value would not be subject
to any event when populated and the mutable extension could not
establish proper coercion or history listening.  A new event
:meth:`.InstanceEvents.refresh_flush` is added which the mutable
extension now makes use of for this use case.
fixes #3427
- Added new event :meth:`.InstanceEvents.refresh_flush`, invoked
when an INSERT or UPDATE level default value fetched via RETURNING
or Python-side default is invoked within the flush process.  This
is to provide a hook that is no longer present as a result of
🎫`3167`, where attribute and validation events are no longer
called within the flush process.
- Added a new semi-public method to :class:`.MutableBase`
:meth:`.MutableBase._get_listen_keys`.  Overriding this method
is needed in the case where a :class:`.MutableBase` subclass needs
events to propagate for attribute keys other than the key to which
the mutable type is associated with, when intercepting the
:meth:`.InstanceEvents.refresh` or
:meth:`.InstanceEvents.refresh_flush` events.  The current example of
this is composites using :class:`.MutableComposite`.
2015-05-21 14:21:01 -04:00
Mike Bayer 164f2ad2f4 flake8 some tests 2015-05-21 13:43:37 -04:00
Mike Bayer 3531a92416 Merge branch 'mutable-dict-update' of https://bitbucket.org/goodscloud/sqlalchemy into pr27 2014-08-25 19:13:47 -04:00
Mike Bayer 8c8d6ee95d Merge branch 'mutable-dict-coerce-fix' of https://bitbucket.org/goodscloud/sqlalchemy into pr27 2014-08-25 19:10:43 -04:00
Matt Chisholm 88f7ec6a0e 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.
2014-08-09 11:03:10 +02:00
Matt Chisholm 2645c84277 add update() support to MutableDict 2014-08-09 11:02:01 +02:00
Mike Bayer 1cb94d89d5 fix test ordering issues 2014-07-27 22:53:17 -04:00
Thomas Herve e36fb9e87c Return the assigned value in MultableDict.setdefault 2014-06-24 09:55:53 +02:00
Mike Bayer aa12fdb40e - Fixed bug in mutable extension where :class:.MutableDict did not
report change events for the ``setdefault()`` dictionary operation.
fixes #3051
2014-05-14 10:03:24 -04:00
Mike Bayer b9a2b58dd7 - Fixed bug in mutable extension as well as
:func:`.attributes.flag_modified` where the change event would not be
propagated if the attribute had been reassigned to itself.
fixes #2997
2014-03-19 11:09:38 -04: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 786c5fe316 - add a test for pullreq 8
- simplify
2013-06-23 17:53:49 -04:00
Mike Bayer 3a13047fb0 Fixed bug where :class:.MutableDict didn't report a change event
when ``clear()`` was called.
[ticket:2730]
2013-06-03 18:23:23 -04:00
Mike Bayer d89d71d1da The :class:.MutableComposite type did not allow for the
:meth:`.MutableBase.coerce` method to be used, even though
the code seemed to indicate this intent, so this now works
and a brief example is added.  As a side-effect,
the mechanics of this event handler have been changed so that
new :class:`.MutableComposite` types no longer add per-type
global event handlers.  Also in 0.7.10

[ticket:2624]
2012-12-03 19:49:42 -05:00
Mike Bayer dda33be687 cleanup 2012-12-03 19:01:25 -05:00
Mike Bayer 4356741c48 - hstore adjustments 2012-11-17 20:45:17 -05: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 9e56ff1a44 another py3k fix 2012-01-28 16:04:38 -05:00
Mike Bayer 029ae72b2f - [bug] Fixed bug where unpickled object didn't
have enough of its state set up to work
correctly within the unpickle() event established
by the mutable object extension, if the object
needed ORM attribute access within
__eq__() or similar. [ticket:2362]
2012-01-28 13:48:05 -05:00
Mike Bayer d9adb2a4fd - [bug] the value of a composite attribute is now
expired after an insert or update operation, instead
of regenerated in place.  This ensures that a
column value which is expired within a flush
will be loaded first, before the composite
is regenerated using that value.  [ticket:2309]

- [bug] The fix in [ticket:2309] also emits the
"refresh" event when the composite value is
loaded on access, even if all column
values were already present, as is appropriate.
This fixes the "mutable" extension which relies
upon the "load" event to ensure the _parents
dictionary is up to date, fixes [ticket:2308].
Thanks to Scott Torborg for the test case here.
2011-10-26 12:41:18 -04:00
Mike Bayer 409a95adf4 - Fixed bug in the mutable extension whereby
if None or a non-corresponding type were set,
    an error would be raised.  None is now accepted
    which assigns None to all attributes,
    illegal values raise ValueError.
2011-07-01 11:32:07 -04:00
Mike Bayer 287e9d6a77 - Fixed bug in the mutable extension whereby
if the same type were used twice in one
    mapping, the attributes beyond the first
    would not get instrumented.
2011-06-30 10:43:53 -04:00
Mike Bayer 5cac2468b6 - Repaired new "mutable" extension to propagate
events to subclasses correctly; don't
create multiple event listeners for
subclasses either.  [ticket:2180]
2011-06-04 19:43:39 -04:00
Mike Bayer 953d72df6b py3k test fix 2011-05-14 13:54:00 -04:00
Mike Bayer 501b8aec1b - Fixed bugs in sqlalchemy.ext.mutable extension where
`None` was not appropriately handled, replacement
    events were not appropriately handled.
    [ticket:2143]
2011-05-14 10:23:12 -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 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 8ca1e58032 - oracle fixes 2011-01-15 19:50:01 -05:00
Mike Bayer 4f18ce0af5 - add support for pickling with mutable scalars, mutable composites
- add pickle/unpickle events to ORM events.  these are needed
for the mutable extension.
- finish mutable extension documentation, consolidate examples,
add full descriptions
2011-01-02 19:54:31 -05:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer 6d36d4635c - add length to varchars 2010-12-31 11:47:38 -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 b1c90de449 - mutable examples now move into sqlalchemy.ext.mutable
- streamline interfaces, get Mutable/MutableComposite to be as minimal
in usage as possible
- docs for mutable, warnings regrarding mapper events being global
- move MutableType/mutable=True outwards, move orm tests to its
own module, note in all documentation
- still need more events/tests for correct pickling support of
composites, mutables.  in the case of composites its needed
even without mutation.  see [ticket:2009]
2010-12-29 15:04:35 -05:00