summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext
Commit message (Collapse)AuthorAgeFilesLines
* Include missing import in exampleMichael Stewart2017-06-301-0/+1
|
* Support AssociationProxy any() / has() / contains() to another AssociationProxyMike Bayer2017-06-121-36/+68
| | | | | | | | | | | | | | | | | | | 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-0/+13
| | | | | | | | | | | | | | 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/+20
| | | | | | | | | | | 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
* selectin polymorphic loadingMike Bayer2017-06-051-4/+7
| | | | | | | | | | | | | Added a new style of mapper-level inheritance loading "polymorphic selectin". This style of loading emits queries for each subclass in an inheritance hierarchy subsequent to the load of the base object type, using IN to specify the desired primary key values. Fixes: #3948 Change-Id: I59e071c6142354a3f95730046e3dcdfc0e2c4de5
* Don't hard-evaluate non-ORM @declared_attr for AbstractConcreteBaseMike Bayer2017-05-261-1/+5
| | | | | | | | | | | | | | | | 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/+22
| | | | | | | | | | 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-6/+26
| | | | | | | | | | 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
* - give SelectinLoader its own bakery, dont use mapperMike Bayer2017-05-161-1/+2
| | | | | | | | level cache - include SelectinLoader itself in the cache key, though this is currently not critical Change-Id: I8e4bcd579277fbe53d9c7eca3552a0b8ab9d7a39
* Protect against cls weakref becoming NoneMike Bayer2017-05-082-4/+8
| | | | | | | | | | Protected against testing "None" as a class in the case where declarative classes are being garbage collected and new automap prepare() operations are taking place concurrently, very infrequently hitting a weakref that has not been fully acted upon after gc. Change-Id: I32e1dfc5ac46bac4127fe808cfd18368e2fad9dd
* Call proxied collection before invoking creator in associationlist.append()Mike Bayer2017-04-281-1/+2
| | | | | | | | | | | | 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-109/+50
| | | | | | | | | | | | | 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-1/+2
| | | | | | | | | | 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-1/+19
| | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | 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-4/+105
| | | | | | | | | | | 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-21/+192
| | | | | | | | | | | | | | 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
* New features from python 2.7Катаев Денис2017-03-172-3/+3
| | | | | | | After bump minimum supported version to 2.7 (1da9d3752160430c91534a8868ceb8c5ad1451d4), we can use new syntax. Change-Id: Ib064c75a00562e641d132f9c57e5e69744200e05 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/347
* Improve serializer behaviorMike Bayer2017-03-141-1/+1
| | | | | | | | | | 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
* Union the exclude_properties of the inheriting mapper in declarativeMike Bayer2017-01-301-2/+6
| | | | | | | | | | 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/+35
|\
| * Add count(), scalar() to baked queryMike Bayer2017-01-301-1/+35
| | | | | | | | | | Change-Id: I8af0d7b41ae2df384ce5d0ef274732352d81f376 Fixes: #3897
* | Fix nested index_property setter when there is no container valueJeong YunWon2017-01-301-2/+4
|/ | | | | | | | | 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
* - add missing param tagMike Bayer2017-01-281-3/+3
| | | | Change-Id: Ic2cc0bdafbf3f1bc2993a9ad3475530eed91d0f1
* - repair an errant docstring w/o rMike Bayer2017-01-171-2/+2
| | | | Change-Id: I2e9c8dbc79c00b54520748d1d7cae5230a612c96
* Support python3.6Mike Bayer2017-01-136-20/+20
| | | | | | | | | | | 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
* update for 2017 copyrightMike Bayer2017-01-0415-15/+15
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Minor fixes in the ext.hybrid documentation.pr/316Randy Barlow2016-10-231-2/+2
|
* Memoize load_path in all cases, run quick populators for path changeMike Bayer2016-10-171-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | Adds a new variant to the "isnew" state within entity loading for isnew=False, but the load path is new. This is to address the use case of an entity appearing in multiple places in the row in a more generalized way than the fixes in [ticket:3431], [ticket:3811] in that loading.py will be able to tell the populator that this row is not "isnew" but is a "new" path for the entity. For the moment, the new information is only being applied to the use of "quick" populators so that simple column loads can take place on top of a deferred loader from elsewhere in the row. As part of this change, state.load_path() will now always be populated with the "path" that was in effect when this state was originally loaded, which for multi-path loads of the same entity is still non-deterministic. Ideally there'd be some kind of "here's all the paths that loaded this state and how" type of data structure though it's not clear if that could be done while maintaining performance. Fixes: #3822 Change-Id: Ib915365353dfcca09e15c24001a8581113b97d5e
* Assemble "don't joinedload other side" rule using query._current_pathMike Bayer2016-10-171-2/+6
| | | | | | | | | 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
* Remove some legacy dead code from the declared_attr logicpr/315Pierre Jaury2016-10-161-3/+0
| | | | | The second 'if' condition was never called because the original condition always returns.
* spelling: Postgresql -> PostgreSQLVille Skyttä2016-10-082-5/+5
|
* Spelling fixesVille Skyttä2016-10-081-1/+1
|
* Check for __clause_element__() in ORM insert/updateMike Bayer2016-10-051-1/+1
| | | | | | | | | | | | | | | | ORM attributes can now be assigned any object that is has a ``__clause_element__()`` attribute, which will result in inline SQL the way any :class:`.ClauseElement` class does. This covers other mapped attributes not otherwise transformed by further expression constructs. As part of this, it was considered that we could add __clause_element__() to ClauseElement, however this causes endless loops in a "while" pattern and this pattern has been identified in third party libraries. Add a test to ensure we never make that change. Change-Id: I9e15b3f1c4883fd3909acbf7dc81d034c6e3ce1d Fixes: #3802
* - some documentation hitsMike Bayer2016-10-011-0/+9
| | | | Change-Id: I468fe70168804b08cf0d5e8b57e235bca904b1ff
* Remove extra "return" statement in orm.ext.declared_attr.cascading examplesDmitry Bogun2016-10-011-8/+5
| | | | | | | Also improves some naming in the examples. Change-Id: I51e5b1d9a730885aed10e5e6ade2123f5e736359 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/306
* Add docstring to declarative_baseFrazer McLean2016-08-061-0/+6
| | | | | Change-Id: I5ad44362515908592f1e8b1e6254a5270d43234a Pull-request: https://github.com/zzzeek/sqlalchemy/pull/295
* Fix reference to _declarative_constructor in docstringMichael Williamson2016-07-251-1/+1
|
* Merge "Add `default` parameter for `index_property`"mike bayer2016-07-131-4/+31
|\
| * Add `default` parameter for `index_property`Jeong YunWon2016-07-111-4/+31
| | | | | | | | | | | | And force to use keyword arguments for trivial parameters in index_property Change-Id: I12a178128182f77a2d06b52d7e36f59a36b45a33
* | Fix issue with unbaking subqueriesMark Hahnenberg2016-07-121-1/+2
|/ | | | | | | | | | 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-1/+1
| | | | | | | 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-2/+15
| | | | | | | | | | | | | | | 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/+320
| | | | | | | | | 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-0/+10
| | | | | | | | | 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
* Convert readthedocs link for their .org -> .io migration for hosted projectspr/278Adam Chainz2016-05-291-1/+1
| | | | | | | | As per their email ‘Changes to project subdomains’: > Starting today, Read the Docs will start hosting projects from subdomains on the domain readthedocs.io, instead of on readthedocs.org. This change addresses some security concerns around site cookies while hosting user generated data on the same domain as our dashboard. Test Plan: Manually visited all the links I’ve modified.
* Spelling fixes: "the a"Ville Skyttä2016-05-051-1/+1
|
* Propagate hybrid properties / infoMike Bayer2016-04-181-1/+12
| | | | | | | | | | | 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-5/+25
| | | | | | | | | | | | 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
* Mention the correct way of adding multiple attributes which refer to the ↵pr/257Eoghan Murray2016-04-071-1/+2
| | | | same column