summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative
Commit message (Collapse)AuthorAgeFilesLines
* - flake8 for lib passesMike Bayer2019-01-051-1/+0
| | | | Change-Id: I0d7f5105f838a0275f3c240441bdcdc9ae7444d0
* flake8 refactor - extMike Bayer2019-01-052-8/+12
| | | | | | | | | | | | A full rewrite of all imports and pep8 formatting using zimports, black, commits are broken into sections. Directories included in this commit: lib/sqlalchemy/ext/ Change-Id: I3dd7aed3f42675e9ada64446ffd2758db7c3bc93 (cherry picked from commit 0716a292e03040ad4f96b890691b9e2c888ec11d)
* - do a broken zimports run on libMike Bayer2019-01-054-54/+58
|
* step 1, straight black -l 79 runMike Bayer2019-01-054-240/+348
| | | | includes adjustment to setup.py to recognize __version__ correctly
* "left" -> "accidentally placed at"Mike Bayer2018-12-021-2/+2
| | | | | | | | | | | | since "left" is kind of ambiguous, use more explicit terminology here. Also update the test to use a positive assertion that the warning is emitted; quote the attribute name. Change-Id: Ic2284c200a26b32b2da063cfaf6d59547309d587 References: https://github.com/zzzeek/sqlalchemy/pull/488 (cherry picked from commit eacb31a89fe883edd0ada7f2724239c1f8c5b685)
* Warn for lower-case column attribute on declarativeMike Bayer2018-11-261-0/+14
| | | | | | | | | | A warning is emitted in the case that a :func:`.column` object is applied to a declarative class, as it seems likely this intended to be a :class:`.Column` object. Fixes: #4374 Change-Id: I2e617ef65547162e3ba6587c168548ad0cf6203d (cherry picked from commit 6ec40eca1a03a9156ee82f3ce75850778220b39e)
* Move pk on single-inh subclass check below conflict resolution checkTom Manderson2018-10-301-5/+5
| | | | | | | | | | | | | The column conflict resolution technique discussed at :ref:`declarative_column_conflicts` is now functional for a :class:`.Column` that is also a primary key column. Previously, a check for primary key columns declared on a single-inheritance subclass would occur before the column copy were allowed to pass. Fixes: #4352 Change-Id: Id4c025da53c28e58db6b549fe398f25f8a90d355 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/483 (cherry picked from commit 3ed79a5c18c14d842280805d1dae8a9c99ec8f18)
* Check more specifically for hybrid attr and not mapped propertyMike Bayer2018-10-201-1/+2
| | | | | | | | | | | Fixed regression caused by :ticket:`4326` in version 1.2.12 where using :class:`.declared_attr` with a mixin in conjunction with :func:`.orm.synonym` would fail to map the synonym properly to an inherited subclass. Fixes: #4350 Change-Id: Ib2a9b6a125a2ac7c7ff80201746b7f10e5596226 (cherry picked from commit 9335c24d6c98033f4aa1ceafd23a70b88c8ae811)
* Unwrap Proxy objects when scanning declared_attrMike Bayer2018-08-231-3/+13
| | | | | | | | | | | | | Fixed bug where the declarative scan for attributes would receive the expression proxy delivered by a hybrid attribute at the class level, and not the hybrid attribute itself, when receiving the descriptor via the ``@declared_attr`` callable on a subclass of an already-mapped class. This would lead to an attribute that did not report itself as a hybrid when viewed within :attr:`.Mapper.all_orm_descriptors`. Fixes: #4326 Change-Id: I582d03f05c3768b3344f93e3791240e9e69b9d1e (cherry picked from commit 626356842d77d4ec6427b3bfc04bdff93d24d246)
* Accommodate for classically mapped base classes in declarativeMike Bayer2018-08-171-8/+45
| | | | | | | | | | | | | | | | Fixed issue in previously untested use case, allowing a declarative mapped class to inherit from a classically-mapped class outside of the declarative base, including that it accommodates for unmapped intermediate classes. An unmapped intermediate class may specify ``__abstract__``, which is now interpreted correctly, or the intermediate class can remain unmarked, and the classically mapped base class will be detected within the hierarchy regardless. In order to anticipate existing scenarios which may be mixing in classical mappings into existing declarative hierarchies, an error is now raised if multiple mapped bases are detected for a given class. Fixes: #4321 Change-Id: I8604ecfd170d2589d9d1b1c87ba303762071fc30 (cherry picked from commit 4c931b2ec7e0f09ac8c3ebe28c794f5858d54efb)
* Don't warn for mixin-based __table_args__, __mapper_args__ declared_attrMike Bayer2018-03-211-2/+3
| | | | | | | | | | | | | Removed a warning that would be emitted when calling upon ``__table_args__``, ``__mapper_args__`` as named with a ``@declared_attr`` method, when called from a non-mapped declarative mixin. Calling these directly is documented as the approach to use when one is overidding one of these methods on a mapped class. The warning still emits for regular attribute names. Change-Id: Iae7ed0bd625a2c163c910aa777cef4779128580a Fixes: #4221 (cherry picked from commit 37955a52995cdbb66a9d5835c20ee58fb98ddffc)
* Rework synonym, synonym_for documentationMike Bayer2018-01-241-11/+26
| | | | | | | | The map_column example was incorrect, and overall the purpose of this parameter as well as that of synonym_for was not explained; examples added along with more encouragement to use hybrids. Change-Id: I20bd286f541f798daa81fa598c0f31db1f5aa6ed
* happy new yearMike Bayer2018-01-124-4/+4
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Warnings for @declared_attr.cascadingticket_4091Mike Bayer2017-09-262-8/+52
| | | | | | | | | | | | | | | | | | | | | A warning is emitted if a subclass attempts to override an attribute that was declared on a superclass using ``@declared_attr.cascading`` that the overridden attribute will be ignored. This use case cannot be fully supported down to further subclasses without more complex development efforts, so for consistency the "cascading" is honored all the way down regardless of overriding attributes. A warning is emitted if the ``@declared_attr.cascading`` attribute is used with a special declarative name such as ``__tablename__``, as this has no effect. Ensure that documenation refers to the current inconsistency that __tablename__ can be overridden by subclasses however @declared_attr.cascading cannot. Fixes: #4091 Fixes: #4092 Change-Id: I3aecdb2f99d408e404a1223f5ad86ae3c7fdf036
* 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
* 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
* Protect against cls weakref becoming NoneMike Bayer2017-05-081-2/+6
| | | | | | | | | | 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
* 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
* Support python3.6Mike Bayer2017-01-131-1/+1
| | | | | | | | | | | 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-044-4/+4
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* 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.
* - 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
|
* Mention the correct way of adding multiple attributes which refer to the ↵pr/257Eoghan Murray2016-04-071-1/+2
| | | | same column
* - happy new yearMike Bayer2016-01-294-4/+4
|
* - cross link for concrete helper classesMike Bayer2016-01-201-0/+16
| | | | | - remove redundant concrete helper docs from declarative docs, two places is enough
* py2k: accept unicode literals on :func:`backref`, toopr/212Nils Philippsen2015-11-251-1/+2
| | | | | | | | 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
* - Fixed bug in :class:`.AbstractConcreteBase` extension whereMike Bayer2015-07-132-2/+12
| | | | | | | | | 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
* - Fixed a regression regarding the :meth:`.MapperEvents.instrument_class`Mike Bayer2015-04-262-18/+13
| | | | | | | | | | | | | | | | | 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
* - add the "strict" version of this lookup for __abstract__ as well,Mike Bayer2015-04-241-2/+2
| | | | fixes #3383
* - Fixed regression regarding the declarative ``__declare_first__``Mike Bayer2015-04-241-9/+11
| | | | | | and ``__declare_last__`` accessors where these would no longer be called on the superclass of the declarative base. fixes #3383
* - Loosened some restrictions that were added to ``@declared_attr``Mike Bayer2015-03-181-9/+6
| | | | | | | | | | | | | 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
* - ensure as_declarative is part of __all__ hereMike Bayer2015-03-121-0/+1
|
* - Fixed bug where using an ``__abstract__`` mixin in the middleMike Bayer2015-03-101-0/+21
| | | | | | | 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
* - copyright 2015Mike Bayer2015-03-104-4/+4
|
* - repair issue in declared_attr.cascading such that within aMike Bayer2015-02-241-0/+2
| | | | | | | | | 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.
* - strategies + declarativeMike Bayer2015-01-041-0/+10
|
* Maul the evaulate & friends typoPriit Laes2014-12-191-1/+1
|
* - squash-merge the improve_toc branch, which moves all the Sphinx stylingMike Bayer2014-12-171-1371/+0
| | | | | | and extensions into an external library, and also reorganizes most large documentation pages into many small areas to reduce scrolling and better present the context into a more fine-grained hierarchy.
* - Fixed "'NoneType' object has no attribute 'concrete'" errorMike Bayer2014-10-061-1/+1
| | | | | | when using :class:`.AbstractConcreteBase` in conjunction with a subclass that declares ``__abstract__``. fixes #3185
* commentsMike Bayer2014-09-261-3/+8
|
* - refactor of declarative, break up into indiviudal methodsMike Bayer2014-09-253-338/+654
| | | | | | | | | | | | | | | | | | | | | | | 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
* - Fixed an unlikely race condition observed in some exotic end-userMike Bayer2014-09-181-1/+6
| | | | | | | | setups, where the attempt to check for "duplicate class name" in declarative would hit upon a not-totally-cleaned-up weak reference related to some other class being removed; the check here now ensures the weakref still references an object before calling upon it further. fixes #3208
* PEP8 style fixesBrian Jarrett2014-07-134-93/+96
|
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-094-4/+8
| | | | to get all flake8 passing
* - Fixed bug when the declarative ``__abstract__`` flag was not beingMike Bayer2014-06-251-1/+1
| | | | | | | 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
* - The ``__mapper_args__`` dictionary is copied from a declarativeMike Bayer2014-05-301-1/+4
| | | | | | | | | 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
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-2/+2
| | | | Found using: https://github.com/intgr/topy