summaryrefslogtreecommitdiff
path: root/test/ext
Commit message (Collapse)AuthorAgeFilesLines
* Support AssociationProxy any() / has() / contains() to another AssociationProxyMike Bayer2017-06-121-1/+152
| | | | | | | | | | | | | | | | | | | The :meth:`.AssociationProxy.any`, :meth:`.AssociationProxy.has` and :meth:`.AssociationProxy.contains` comparison methods now support linkage to an attribute that is itself also an :class:`.AssociationProxy`, recursively. After some initial attempts it's clear that the any() / has() of AssociationProxy needed to be reworked into a generic _criterion_exists() to allow this to work recursively without excess complexity. For the case of the multi-linked associationproxy, the usual checks of "any()" / "has()" correctness simply don't take place; for a single-link association proxy the error checking logic that takes place in relationship() has been ported to the local any() / has() methods. Change-Id: Ic5aed2a4e910b8138a737d215430113c31cce856 Fixes: #3769
* Warn when declared_attr.cascading detected on mapped classMike Bayer2017-06-062-2/+39
| | | | | | | | | | | | | | A warning is emitted if the :attr:`.declared_attr.cascading` modifier is used with a declarative attribute that is itself declared on a class that is to be mapped, as opposed to a declarative mixin class or ``__abstract__`` class. The :attr:`.declared_attr.cascading` modifier currently only applies to mixin/abstract classes. Also add a test for @declared_attr.cascading when used on an attribute on __abstract__. Change-Id: Ib1b9dbe373e8be1cf24eadfed224a8988b3cd95d Fixes: #3847
* Implement in-place mutation operators for MutableSet, MutableListMike Bayer2017-06-051-0/+60
| | | | | | | | | | | Implemented in-place mutation operators ``__ior__``, ``__iand__``, ``__ixor__`` and ``__isub__`` for :class:`.mutable.MutableSet` and ``__iadd__`` for :class:`.mutable.MutableList` so that change events are fired off when these mutator methods are used to alter the collection. Change-Id: Ib357a96d3b06c5deb6b53eb304a8b9f1dc9e9ede Fixes: #3853
* Don't hard-evaluate non-ORM @declared_attr for AbstractConcreteBaseMike Bayer2017-05-261-0/+63
| | | | | | | | | | | | | | | | Fixed bug where using :class:`.declared_attr` on an :class:`.AbstractConcreteBase` where a particular return value were some non-mapped symbol, including ``None``, would cause the attribute to hard-evaluate just once and store the value to the object dictionary, not allowing it to invoke for subclasses. This behavior is normal when :class:`.declared_attr` is on a mapped class, and does not occur on a mixin or abstract class. Since :class:`.AbstractConcreteBase` is both "abstract" and actually "mapped", a special exception case is made here so that the "abstract" behavior takes precedence for :class:`.declared_attr`. Change-Id: I6160ebb3a52c441d6a4b663c8c9bbac6d37fa417 Fixes: #3848
* Add AttributeEvents.modifiedMike Bayer2017-05-231-0/+16
| | | | | | | | | | Added new event handler :meth:`.AttributeEvents.modified` which is triggered when the func:`.attributes.flag_modified` function is invoked, which is common when using the :mod:`sqlalchemy.ext.mutable` extension module. Change-Id: Ic152f1d5c53087d780b24ed7f1f1571527b9e8fc Fixes: #3303
* Add new configuration, inspection for baked queriesMike Bayer2017-05-171-0/+35
| | | | | | | | | | Added new flag :paramref:`.Session.enable_baked_queries` to the :class:`.Session` to allow baked queries to be disabled session-wide, reducing memory use. Also added new :class:`.Bakery` wrapper so that the bakery returned by :paramref:`.BakedQuery.bakery` can be inspected. Change-Id: I5657af7a99d2b24c89d6aee1343f432728e3f807
* Call proxied collection before invoking creator in associationlist.append()Mike Bayer2017-04-281-1/+99
| | | | | | | | | | | | Improved the association proxy list collection so that premature autoflush against a newly created association object can be prevented in the case where ``list.append()`` is being used, and a lazy load would be invoked when the association proxy accesses the endpoint collection. The endpoint collection is now accessed first before the creator is invoked to produce the association object. Change-Id: I008a6dbdfe5b1c0dfd02189c3d954d83a65f3fc5 Fixes: #3941
* Use baked lazyloading by defaultMike Bayer2017-04-131-142/+113
| | | | | | | | | | | | | The ``lazy="select"`` loader strategy now makes used of the :class:`.BakedQuery` query caching system in all cases. This removes most overhead of generating a :class:`.Query` object and running it into a :func:`.select` and then string SQL statement from the process of lazy-loading related collections and objects. The "baked" lazy loader has also been improved such that it can now cache in most cases where query load options are used. Change-Id: Ic96792fffaa045ae9aa0a4657d6d29235d3efb85 Fixes: #3954
* Ensure we check that SQL expression has an .info attributeMike Bayer2017-04-041-2/+4
| | | | | | | | | | Fixed regression released in 1.1.8 due to :ticket:`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
* Track SchemaEventTarget types in as_mutable()Mike Bayer2017-03-301-0/+43
| | | | | | | | | | | | | | 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
* Add bindparams support for baked Result count() methodMalaclypse The Younger2017-03-301-0/+28
| | | | | | | | | | Added support for bound parameters, e.g. those normally set up via :meth:`.Query.params`, to the :meth:`.baked.Result.count` method. Previously, support for parameters were omitted. Pull request courtesy Pat Deegan. Change-Id: I8c33548cf2a483699767e459731694c8cadebff6 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/350
* Support hybrids/composites with bulk updatesMike Bayer2017-03-221-1/+159
| | | | | | | | | | | The :meth:`.Query.update` method can now accommodate both hybrid attributes as well as composite attributes as a source of the key to be placed in the SET clause. For hybrids, an additional decorator :meth:`.hybrid_property.update_expression` is supplied for which the user supplies a tuple-returning function. Change-Id: I15e97b02381d553f30b3301308155e19128d2cfb Fixes: #3229
* Allow reuse of hybrid_property across subclassesDiana Clarke2017-03-211-0/+113
| | | | | | | | | | | | | | The :class:`sqlalchemy.ext.hybrid.hybrid_property` class now supports calling mutators like ``@setter``, ``@expression`` etc. multiple times across subclasses, and now provides a ``@getter`` mutator, so that a particular hybrid can be repurposed across subclasses or other classes. This now matches the behavior of ``@property`` in standard Python. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #3911 Fixes: #3912 Change-Id: Iff033d8ccaae20ded9289cbfa789c376759381f5
* Improve serializer behaviorMike Bayer2017-03-141-16/+32
| | | | | | | | | | Fix an issue where the Annotated system needs to have a __reduce__ method, also see why we can't default to HIGHEST_PROTOCOL. This latter part might not be a good idea until 1.2 for compatibility reasons. Change-Id: I0239e38259fc768c9e3b6c448c29161e271a969c Fixes: #3918
* Add tests for empty association set comparisonMike Bayer2017-03-131-1/+25
| | | | | | | | This seems to only occur in python 2.6, adding tests to ensure it stays Change-Id: Id714680970bf1f70e2fe06b0c8688b7c5a6b6b0c Fixes: #3265
* Make all tests to be PEP8 compliantKhairi Hafsham2017-02-0714-338/+324
| | | | | | | | tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
* Union the exclude_properties of the inheriting mapper in declarativeMike Bayer2017-01-301-1/+38
| | | | | | | | | | Fixed bug where the "automatic exclude" feature of declarative that ensures a column local to a single table inheritance subclass does not appear as an attribute on other derivations of the base would not take effect for multiple levels of subclassing from the base. Change-Id: Ibf67b631b4870dd1bd159f7d6085549d299fffe0 Fixes: #3895
* Merge "Add count(), scalar() to baked query"mike bayer2017-01-301-1/+38
|\
| * Add count(), scalar() to baked queryMike Bayer2017-01-301-1/+38
| | | | | | | | | | Change-Id: I8af0d7b41ae2df384ce5d0ef274732352d81f376 Fixes: #3897
* | Fix nested index_property setter when there is no container valueJeong YunWon2017-01-301-0/+14
|/ | | | | | | | | Fixed bug in new :mod:`sqlalchemy.ext.indexable` extension where setting of a property that itself refers to another property would fail. Fixes: #3901 Change-Id: I203a66117e2399afee11a34f43f0e93adfc6d571
* Support python3.6Mike Bayer2017-01-132-4/+4
| | | | | | | | | | | Corrects some warnings and adds tox config. Adds DeprecationWarning to the error category. Large sweep for string literals w/ backslashes as this is common in docstrings Co-authored-by: Andrii Soldatenko Fixes: #3886 Change-Id: Ia7c838dfbbe70b262622ed0803d581edc736e085 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/337
* Assemble "don't joinedload other side" rule using query._current_pathMike Bayer2016-10-171-2/+70
| | | | | | | | | Discovered during testing for [ticket:3822], the rule added for [ticket:1495] will fail if the source object has propagated options set up, which add elements to query._current_path. Fixes: #3824 Change-Id: I3d96c96fee5f9b247f739d2136d18681ac61f2fe
* Enhance "raise" strategy to include "raise_on_sql" optionMike Bayer2016-10-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | The "raise_on_sql" option differentiates from "raise" in that firing a lazy loader is OK as long as it does a simple get from identity map. Whereas "raise" is more useful for the case that objects are to be detached. As part of this, refactors the strategy initiation logic a bit so that a LoaderStrategy itself knows what "key" was used to create it, thus allowing variants of a single strategy based on what the "lazy" argument is. To achieve this we have to also get rid of _get_strategy_by_cls(). Everything here is internal with the one exception of an apparently undocumented, but not underscored, "strategy_class" key on relationship(). Though it's not clear what "strategy_class" accomplishes; at this point the strategy system is extensible using Property.strategy_for(). Fixes: #3812 Change-Id: I812ad878ea5cf764e15f6f71cb39eee78a645d88
* Add the "triggering mapper" to the configure_mappers error message.John Perkins2016-09-201-3/+4
| | | | | | | | | | There are cases where the originating mapper name is not present in the exception message, such as relationship initialization against an unmapped class. Ensure the originating mapper is named in the string output. Pull-request: https://github.com/zzzeek/sqlalchemy/pull/298 Change-Id: I9f23bfa90b26dde9229ab7ec812eec9ceae48153
* Repair foreign_keys population for Join._refresh_for_new_columnMike Bayer2016-09-151-1/+51
| | | | | | | | | | Fixed bug where setting up a single-table inh subclass of a joined-table subclass which included an extra column would corrupt the foreign keys collection of the mapped table, thereby interfering with the initialization of relationships. Change-Id: I04a0cf98fd456d12d5a5b9e77a46a01246969a63 Fixes: #3797
* Add docstring to declarative_baseFrazer McLean2016-08-061-0/+9
| | | | | Change-Id: I5ad44362515908592f1e8b1e6254a5270d43234a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/295
* - a variety of test adjustments to accomodate for MySQL 5.7Mike Bayer2016-07-241-0/+3
| | | | Change-Id: Ied4245433d0d7b469dae6e7394c4931d8405f387
* Merge "Add `default` parameter for `index_property`"mike bayer2016-07-131-0/+25
|\
| * Add `default` parameter for `index_property`Jeong YunWon2016-07-111-0/+25
| | | | | | | | | | | | And force to use keyword arguments for trivial parameters in index_property Change-Id: I12a178128182f77a2d06b52d7e36f59a36b45a33
* | Fix issue with unbaking subqueriesMark Hahnenberg2016-07-121-12/+21
|/ | | | | | | | | | Fix improper capture of a loop variable inside a lambda during unbaking of subquery eager loaders, which would cause the incorrect query to be invoked. Fixes: #3743 Change-Id: I995110deb8ee2dae8540486729e1ae64578d28fc Pull-request: https://github.com/zzzeek/sqlalchemy/pull/290
* `index_property` catches IndexError as well as KeyErrorJeong YunWon2016-07-051-2/+4
| | | | | | | It was raising AttributeError for key accessing in dict, but raising IndexError for index accessing in array. Change-Id: I58a2252a9e8d7f78cabcefcbe7223a4f3a729115
* Ensure @compiles calls down to the original compilation schemeMike Bayer2016-06-291-4/+47
| | | | | | | | | | | | | | | Made a slight behavioral change in the ``sqlalchemy.ext.compiler`` extension, whereby the existing compilation schemes for an established construct would be removed if that construct was itself didn't already have its own dedicated ``__visit_name__``. This was a rare occurrence in 1.0, however in 1.1 :class:`.postgresql.ARRAY` subclasses :class:`.sqltypes.ARRAY` and has this behavior. As a result, setting up a compilation handler for another dialect such as SQLite would render the main :class:`.postgresql.ARRAY` object no longer compilable. Fixes: #3732 Change-Id: If2c1ada4eeb09157885888e41f529173902f2b49
* Add `sqlalchemy.ext.index` for indexed attributes for ORMJeong YunWon2016-06-151-0/+344
| | | | | | | | | Add `sqlalchemy.ext.index.index_property` which subscribe an index of a column with `Indexable` type. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I238c23131e4fded5dc7f7a25eb02e26008099d00 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/235
* Add schema argument to AutomapBase.prepare()Josh Marlow2016-06-021-1/+36
| | | | | | | | | This allows automap to reflect tables from a schema other than the default without the need to resort to calling MetaData.reflect directly. Change-Id: Ie73cb113bd6d115555c09c5efc33d27ad2c9c512 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/237
* change "psotgresql" to 'postgresql' in decoratorpr/272Mark Sandan2016-05-061-1/+1
|
* Deprecate Mapper.order_byMike Bayer2016-04-191-2/+2
| | | | | | | | | | | This is an old parameter no longer relevant to how SQLAlchemy works, once the Query object was introduced. By deprecating it we establish that we aren't supporting non-working use cases and that we encourage applications to move off of the use of this parameter. Fixes: #3394 Change-Id: I25b9a38142a1537bbcb27d3e8b66a8b265140072
* Propagate hybrid properties / infoMike Bayer2016-04-181-0/+53
| | | | | | | | | | | Keystone and others depend on the .property attribute being "mirrored" when a @hybrid_property is linked directly to a mapped attribute. Restore this linkage and also create a defined behavior for the .info dictionary; it is that of the hybrid itself. Add this behavioral change to the migration notes. Change-Id: I8ac34ef52039387230c648866c5ca15d381f7fee References: #3653
* Honor hybrid property / method docstringsMike Bayer2016-04-181-6/+269
| | | | | | | | | | | | The docstring specified on a hybrid property or method is now honored at the class level, allowing it to work with tools like Sphinx autodoc. The mechanics here necessarily involve some wrapping of expressions to occur for hybrid properties, which may cause them to appear differently using introspection. Fixes: #3653 Change-Id: I02549977fe8b2a051802eed7b00cc532fbc214e3 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/239
* Add `sqlalchemy.ext.mutable.MutableSet`pr/236Jeong YunWon2016-02-131-1/+195
| | | | from https://bitbucket.org/zzzeek/sqlalchemy/issues/3297
* Add `sqlalchemy.ext.mutable.MutableList`Jeong YunWon2016-02-131-1/+218
|
* - Further fixes to :ticket:`3605`, pop method on :class:`.MutableDict`,Mike Bayer2015-12-171-1/+16
| | | | | where the "default" argument was not included. fixes #3605
* - Fixed bug in baked loader system where the systemwide monkeypatchMike Bayer2015-12-151-0/+18
| | | | | | | | 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
* - Added support for the ``dict.pop()`` and ``dict.popitem()`` methodsMike Bayer2015-12-111-0/+32
| | | | | to the :class:`.mutable.MutableDict` class. fixes #3605
* Merge remote-tracking branch 'origin/pr/212'Mike Bayer2015-11-301-0/+23
|\
| * py2k: accept unicode literals on :func:`backref`, toopr/212Nils Philippsen2015-11-251-0/+23
| | | | | | | | | | | | | | | | 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 e6f67f48054d906856f879bc1803ea639aa4b670
* | - close the sessionMike Bayer2015-11-291-0/+2
| |
* | - Fixed an issue in baked queries where the .get() method, used eitherMike Bayer2015-11-291-0/+24
|/ | | | | | | | | 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
* - rewrite the docs and add a test for the bake_queries=TrueMike Bayer2015-11-191-2/+46
| | | | | | | 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
* - exclude this from unpredictable gcMike Bayer2015-10-111-1/+1
|
* - Added the :paramref:`.AssociationProxy.info` parameter to theMike Bayer2015-10-091-0/+20
| | | | | | | | | :class:`.AssociationProxy` constructor, to suit the :attr:`.AssociationProxy.info` accessor that was added in :ticket:`2971`. This is possible because :class:`.AssociationProxy` is constructed explicitly, unlike a hybrid which is constructed implicitly via the decorator syntax. fixes #3551