Commit Graph

410 Commits

Author SHA1 Message Date
Mike Bayer f1fcc92e36 - Further fixes to 🎫3605, pop method on :class:.MutableDict,
where the "default" argument was not included.
fixes #3605

(cherry picked from commit 913858c949)
2015-12-17 11:25:05 -05:00
Mike Bayer c3876fe755 - Fixed bug in baked loader system where the systemwide monkeypatch
for setting up baked lazy loaders would interfere with other
loader strategies that rely on lazy loading as a fallback, e.g.
joined and subquery eager loaders, leading to ``IndexError``
exceptions at mapper configuration time.
fixes #3612

(cherry picked from commit a22b208506)
2015-12-15 21:44:33 -05:00
Mike Bayer 9b7870dd59 - Added support for the `dict.pop() and dict.popitem()` methods
to the :class:`.mutable.MutableDict` class.
fixes #3605

(cherry picked from commit 5710a1e88b)
2015-12-11 11:24:58 -05:00
Nils Philippsen 33c3aded3a py2k: accept unicode literals on :func:backref, too
Fixed bug where in Py2K a unicode literal would not be accepted as the
string name of a class or other argument within declarative using
:func:`.backref` on :func:`.relationship`.

amends commit e6f67f4805

(cherry picked from commit 58f73d2278)
2015-11-30 12:49:12 -05:00
Mike Bayer d4fa1345ff - close the session
(cherry picked from commit 4fcd93afb8)
2015-11-29 21:51:02 -05:00
Mike Bayer 670fd506fe - Fixed an issue in baked queries where the .get() method, used either
directly or within lazy loads, didn't consider the mapper's "get clause"
as part of the cache key, causing bound parameter mismatches if the
clause got re-generated.  This clause is cached by mappers
on the fly but in highly concurrent scenarios may be generated more
than once when first accessed.
fixes #3597

(cherry picked from commit b0308a7b3a)
2015-11-29 11:43:30 -05:00
Mike Bayer e8c2e4a179 - rewrite the docs and add a test for the bake_queries=True
relationship flag; this flag *does* have an effect when the baked
lazy loader plugin has been invoked.  clarify the intent of this
flag as an "opt out" but only has an effect when the baked system
is loaded anyway.  fixes #3572

(cherry picked from commit c7f9aa2818)
2015-11-19 14:24:17 -05:00
Mike Bayer b63229aebe - Added the :paramref:.AssociationProxy.info parameter to the
:class:`.AssociationProxy` constructor, to suit the
:attr:`.AssociationProxy.info` accessor that was added in
🎫`2971`.  This is possible because :class:`.AssociationProxy`
is constructed explicitly, unlike a hybrid which is constructed
implicitly via the decorator syntax.
fixes #3551

(cherry picked from commit 9d08c6abc2)
2015-10-09 18:02:19 -04:00
Eric Siegerman bdac0369b2 Fix sqlalchemy.ext.baked.Result.one_or_none() exception message
Also add a couple of missing tests.
(cherry picked from commit 91255618dd)
2015-09-24 15:32:31 -04:00
Mike Bayer 8c824ddb00 - replicate Query.one_or_none to BakedQuery
- changelog / version note finishing

(cherry picked from commit 5b71858533)
2015-09-24 13:53:26 -04:00
Mike Bayer b68c9ac93e - Fixed bug in :class:.AbstractConcreteBase extension where
a column setup on the ABC base which had a different attribute
name vs. column name would not be correctly mapped on the final
base class.   The failure on 0.9 would be silent whereas on
1.0 it raised an ArgumentError, so may not have been noticed
prior to 1.0.
fixes #3480
2015-07-13 15:39:04 -04:00
Mike Bayer e765c55e8c - Fixed an unexpected-use regression whereby custom :class:.Comparator
objects that made use of the ``__clause_element__()`` method and
returned an object that was an ORM-mapped
:class:`.InstrumentedAttribute` and not explicitly a
:class:`.ColumnElement` would fail to be correctly
handled when passed as an expression to :meth:`.Session.query`.
The logic in 0.9 happened to succeed on this, so this use case is now
supported. fixes #3448
2015-06-11 16:48:00 -04:00
Mike Bayer 343734b95f - repair these tests to use the global manager_of_class fn,
as test_customfinder_pass at least does not provide the
alternate ext manager and in all cases it's the global function
that counts
2015-06-07 17:44:58 -04:00
Mike Bayer 47d29eae8f - changelog for pr bitbucket:54
- alter the approach so that the initial callable is working just like add_criteria/with_criteria
2015-06-03 10:08:33 -04: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 95949db715 - Repair _reinstall_default_lookups to also flip the _extended flag
off again so that test fixtures setup/teardown instrumentation as
expected
- clean up test_extendedattr.py and fix it to no longer leak
itself outside by ensuring _reinstall_default_lookups is always called,
part of #3408
- Fixed bug where when using extended attribute instrumentation system,
the correct exception would not be raised when :func:`.class_mapper`
were called with an invalid input that also happened to not
be weak referencable, such as an integer.
fixes #3408
2015-05-01 12:33:45 -04:00
Mike Bayer 635f06c3eb - turn sessions in ResultTest to autocommit=True just to get them
to clean up automatically.  references #3407
2015-05-01 10:00:23 -04:00
Mike Bayer 4f6e9ccae9 - Fixed bug in association proxy where an any()/has()
on an relationship->scalar non-object attribute comparison would fail,
e.g.
``filter(Parent.some_collection_to_attribute.any(Child.attr == 'foo'))``
fixes #3397
2015-04-28 19:20:01 -04:00
Mike Bayer 6c0f30db81 - Fixed a regression regarding the :meth:.MapperEvents.instrument_class
event where its invocation was moved to be after the class manager's
instrumentation of the class, which is the opposite of what the
documentation for the event explicitly states.  The rationale for the
switch was due to Declarative taking the step of setting up
the full "instrumentation manager" for a class before it was mapped
for the purpose of the new ``@declared_attr`` features
described in :ref:`feature_3150`, but the change was also made
against the classical use of :func:`.mapper` for consistency.
However, SQLSoup relies upon the instrumentation event happening
before any instrumentation under classical mapping.
The behavior is reverted in the case of classical and declarative
mapping, the latter implemented by using a simple memoization
without using class manager.
fixes #3388
2015-04-26 18:22:41 -04:00
Mike Bayer e73f735382 - Fixed regression regarding the declarative `__declare_first__`
and ``__declare_last__`` accessors where these would no longer be
called on the superclass of the declarative base.
fixes #3383
2015-04-24 13:49:09 -04:00
Mike Bayer a3af638e1a - Fixed more regressions caused by NEVER_SET; comparisons
to transient objects with attributes unset would leak NEVER_SET,
and negated_contains_or_equals would do so for any transient
object as the comparison used only the committed value.
Repaired the NEVER_SET cases, fixes #3371, and also made
negated_contains_or_equals() use state_attr_by_column() just
like a non-negated comparison, fixes #3374
2015-04-20 17:38:03 -04:00
Mike Bayer bdcaa0f6ca - The "auto-attach" feature of constraints such as :class:.UniqueConstraint
and :class:`.CheckConstraint` has been further enhanced such that
when the constraint is associated with non-table-bound :class:`.Column`
objects, the constraint will set up event listeners with the
columns themselves such that the constraint auto attaches at the
same time the columns are associated with the table.  This in particular
helps in some edge cases in declarative but is also of general use.
fixes #3341
2015-03-24 10:55:29 -04:00
Mike Bayer cd076470ba - Loosened some restrictions that were added to `@declared_attr`
objects, such that they were prevented from being called outside
of the declarative process; this is related to the enhancements
of #3150 which allow ``@declared_attr`` to return a value that is
cached based on the current class as it's being configured.
The exception raise has been removed, and the behavior changed
so that outside of the declarative process, the function decorated by
``@declared_attr`` is called every time just like a regular
``@property``, without using any caching, as none is available
at this stage.
fixes #3331
2015-03-18 18:57:13 -04:00
Mike Bayer e3b46bd624 - Added a new extension suite :mod:sqlalchemy.ext.baked. This
simple but unusual system allows for a dramatic savings in Python
overhead for the construction and processing of orm :class:`.Query`
objects, from query construction up through rendering of a string
SQL statement.
fixes #3054
2015-03-11 20:31:11 -04:00
Mike Bayer 95e53d0b60 - Fixed bug where using an `__abstract__` mixin in the middle
of a declarative inheritance hierarchy would prevent attributes
and configuration being correctly propagated from the base class
to the inheriting class.
fixes #3219 fixes #3240
2015-03-10 17:21:46 -04:00
Gilles Dartiguelongue 9fee9cb87e Fix slice addressing of _AssociationList with python3 2015-03-10 14:28:50 -04:00
Mike Bayer 3a56c4f019 - repair issue in declared_attr.cascading such that within a
subclass, the value returned by the descriptor is not available
because the superclass is already mapped with the InstrumentedAttribute,
until the subclass is mapped.  We add a setattr() to set up that
attribute so that the __mapper_args__ hook and possibly others
have access to the "cascaded" version of the attribute within
the call.
2015-02-24 15:29:30 -05:00
Mike Bayer 2f6ec41dc9 - fix test for new events 2015-01-04 19:43:48 -05:00
Mike Bayer 902c8d480b - some profile changes likely due to the change in event listening
on engines
2014-12-08 01:22:37 -05:00
Mike Bayer 5a10b6a455 - Fixed "'NoneType' object has no attribute 'concrete'" error
when using :class:`.AbstractConcreteBase` in conjunction with
a subclass that declares ``__abstract__``.
fixes #3185
2014-10-06 18:33:05 -04:00
Mike Bayer 7f82c55fa7 - refactor of declarative, break up into indiviudal methods
that are now affixed to _MapperConfig
- declarative now creates column copies ahead of time
so that they are ready to go for a declared_attr
- overhaul of declared_attr; memoization, cascading modifier
- A relationship set up with :class:`.declared_attr` on
a :class:`.AbstractConcreteBase` base class will now be configured
on the abstract base mapping automatically, in addition to being
set up on descendant concrete classes as usual.
fixes #2670
- The :class:`.declared_attr` construct has newly improved
behaviors and features in conjunction with declarative.  The
decorated function will now have access to the final column
copies present on the local mixin when invoked, and will also
be invoked exactly once for each mapped class, the returned result
being memoized.   A new modifier :attr:`.declared_attr.cascading`
is added as well. fixes #3150
- the original plan for #3150 has been scaled back; by copying
mixin columns up front and memoizing, we don't actually need
the "map properties later" thing.
- full docs + migration notes
2014-09-25 21:08:17 -04:00
Mike Bayer 360477cc3a - flake8 all of test/ext/declarative 2014-09-23 13:25:22 -04:00
Mike Bayer 5508388f03 - The :mod:sqlalchemy.ext.automap extension will now set
``cascade="all, delete-orphan"`` automatically on a one-to-many
relationship/backref where the foreign key is detected as containing
one or more non-nullable columns.  This argument is present in the
keywords passed to :func:`.automap.generate_relationship` in this
case and can still be overridden.  Additionally, if the
:class:`.ForeignKeyConstraint` specifies ``ondelete="CASCADE"``
for a non-nullable or ``ondelete="SET NULL"`` for a nullable set
of columns, the argument ``passive_deletes=True`` is also added to the
relationship.  Note that not all backends support reflection of
ondelete, but backends that do include Postgresql and MySQL.
fixes #3210
2014-09-22 23:00:45 -04:00
Mike Bayer 1dacbb25f8 pep8/flake8 2014-09-22 22:22:09 -04:00
Mike Bayer 14d2bb074c - Fixed bug in ordering list where the order of items would be
thrown off during a collection replace event, if the
reorder_on_append flag were set to True.  The fix ensures that the
ordering list only impacts the list that is explicitly associated
with the object.
fixes #3191
2014-09-10 14:14:50 -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
Mike Bayer ea85c7053d - 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
2014-08-13 19:20:44 -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 0bf33068f4 - ensure all tests are named test_* 2014-07-30 12:18:33 -04:00
Mike Bayer 1cb94d89d5 fix test ordering issues 2014-07-27 22:53:17 -04:00
Mike Bayer fe878f5aff - more pg8000 tests passing 2014-07-25 16:39:44 -04:00
Mike Bayer 41563b5f5a Merged in therve/bug-3093/bug/3093 (pull request #24)
Return the assigned value in MultableDict.setdefault
2014-07-06 17:12:23 -04:00
Mike Bayer ca58fa5d93 - Fixed bug when the declarative `__abstract__` flag was not being
distinguished for when it was actually the value ``False``.
The ``__abstract__`` flag needs to acutally evaluate to a True
value at the level being tested.
fixes #3097
2014-06-25 14:30:25 -04:00
Thomas Herve e36fb9e87c Return the assigned value in MultableDict.setdefault 2014-06-24 09:55:53 +02:00
Mike Bayer a1bbf3a005 - Additional checks have been added for the case where an inheriting
mapper is implicitly combining one of its column-based attributes
with that of the parent, where those columns normally don't necessarily
share the same value.  This is an extension of an existing check that
was added via 🎫`1892`; however this new check emits only a
warning, instead of an exception, to allow for applications that may
be relying upon the existing behavior.
fixes #3042
2014-06-20 18:47:28 -04:00
Mike Bayer 9c96d96d0f - fix this test for MySQL, needs InnoDB 2014-05-30 18:09:11 -04:00
Mike Bayer 8daa6ccfb0 - The `__mapper_args__` dictionary is copied from a declarative
mixin or abstract class when accessed, so that modifications made
to this dictionary by declarative itself won't conflict with that
of other mappings.  The dictionary is modified regarding the
``version_id_col`` and ``polymorphic_on`` arguments, replacing the
column within with the one that is officially mapped to the local
class/table. fixes #3062
2014-05-30 15:36:13 -04:00