summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/mapper.py
Commit message (Collapse)AuthorAgeFilesLines
...
* New features from python 2.7Катаев Денис2017-03-171-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
* Don't post-SELECT columns w/o a server default/onupdate for eager_defaultsMike Bayer2017-02-081-0/+16
| | | | | | | | | | | | | | Fixed a major inefficiency in the "eager_defaults" feature whereby an unnecessary SELECT would be emitted for column values where the ORM had explicitly inserted NULL, corresponding to attributes that were unset on the object but did not have any server default specified, as well as expired attributes on update that nevertheless had no server onupdate set up. As these columns are not part of the RETURNING that eager_defaults tries to use, they should not be post-SELECTed either. Change-Id: I0d4f1e9d3d9717d68dcc0592f69456a1f1c36df8 Fixes: #3909
* Support python3.6Mike Bayer2017-01-131-3/+3
| | | | | | | | | | | 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-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* Use configured props for mapper.attrs, mapper.all_orm_descriptorsMike Bayer2016-11-101-2/+2
| | | | | | | | | | | | Fixed bug where the :attr:`.Mapper.attrs`, :attr:`.Mapper.all_orm_descriptors` and other derived attributes would fail to refresh when mapper properties or other ORM constructs were added to the mapper/class after these accessors were first called. (also trying different ways to get the changelog to merge cleanly) Change-Id: Iaecdb4b3d8c3a3b44302a5880476e60a1f4e27d9 Fixes: #3778
* Ensure attribute keys used for bulk update pk setMike Bayer2016-11-101-0/+10
| | | | | | | | Fixed bug in :meth:`.Session.bulk_update_mappings` where an alternate-named primary key attribute would not track properly into the UPDATE statement. Change-Id: I33e9140f45827772768fa548adcfeb4dbfc2208d Fixes: #3849
* Ensure mapper.polymorphic_on is polymorphic_prop.columns[0]Mike Bayer2016-09-211-11/+8
| | | | | | | | | Fixed bug where joined eager loading would fail for a polymorphically- loaded mapper, where the polymorphic_on was set to an un-mapped expression such as a CASE expression. Change-Id: Iffe68196aaac592165c89684f09f4c06cd78ce54 Fixes: #3800
* Add the "triggering mapper" to the configure_mappers error message.John Perkins2016-09-201-2/+3
| | | | | | | | | | 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
* Raise when two validators conflictMike Bayer2016-08-261-0/+5
| | | | | | | | Two @validates decorators that make use of the same name is not supported. Raise an exception. Change-Id: Ia3e89ffdc9ef345a0de258e2ac0ac5e0bd421c61 Fixes: #3776
* Allow Table._reset_exported to silently passMike Bayer2016-07-241-2/+0
| | | | | | | | | | | Fixed bug in :class:`.Table` where the internal method ``_reset_exported()`` would corrupt the state of the object. This method is intended for selectable objects and is called by the ORM in some cases; an erroneous mapper configuration would could lead the ORM to call this on on a :class:`.Table` object. Change-Id: I63fa34ee0cdf16358bb125c556390df79758bcbc Fixes: #3755
* Corrects some references in ORM documentation.pr/267Jeffrey Finkelstein2016-05-031-8/+10
|
* Deprecate Mapper.order_byMike Bayer2016-04-191-0/+9
| | | | | | | | | | | 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
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - Added new parameter :paramref:`.orm.mapper.passive_deletes` toMike Bayer2016-01-201-1/+42
| | | | | | | | available mapper options. This allows a DELETE to proceed for a joined-table inheritance mapping against the base table only, while allowing for ON DELETE CASCADE to handle deleting the row from the subclass tables. fixes #2349
* - Fixed issue where two same-named relationships that refer toMike Bayer2016-01-191-1/+6
| | | | | | | | a base class and a concrete-inherited subclass would raise an error if those relationships were set up using "backref", while setting up the identical configuration using relationship() instead with the conflicting names would succeed, as is allowed in the case of a concrete mapping. fixes #3630
* - Fixed bug in :meth:`.Update.return_defaults` which would cause allMike Bayer2015-12-141-1/+13
| | | | | | | | | | | | | | insert-default holding columns not otherwise included in the SET clause (such as primary key cols) to get rendered into the RETURNING even though this is an UPDATE. - Major fixes to the :paramref:`.Mapper.eager_defaults` flag, this flag would not be honored correctly in the case that multiple UPDATE statements were to be emitted, either as part of a flush or a bulk update operation. Additionally, RETURNING would be emitted unnecessarily within update statements. fixes #3609
* - Added a new type-level modifier :meth:`.TypeEngine.evaluates_none`Mike Bayer2015-09-191-2/+2
| | | | | | | | | | | | | which indicates to the ORM that a positive set of None should be persisted as the value NULL, instead of omitting the column from the INSERT statement. This feature is used both as part of the implementation for :ticket:`3514` as well as a standalone feature available on any type. fixes #3250 - add new documentation section illustrating the "how to force null" use case of #3250 - alter our change from #3514 so that the class-level flag is now called "should_evaluate_none"; so that "evaluates_none" is now a generative method.
* - add a new FAQ recipe for "walk all objects", replacing the needMike Bayer2015-09-101-4/+13
| | | | | | to use mapper.cascade_iterator() for this purpose as it was not really designed for that use case. Add docs to cascade_iterator() pointing to the recipe. fixes #3498
* - re-document and fully cross link all of configure_mappers(),Mike Bayer2015-08-241-1/+27
| | | | mapper_configured(), after_configured(), and before_configured().
* - merge of ticket_3514 None-handling branchMike Bayer2015-08-171-1/+15
| | | | | | | | | | | | | | | | - Fixes to the ORM and to the postgresql JSON type regarding the ``None`` constant in conjunction with the Postgresql :class:`.JSON` type. When the :paramref:`.JSON.none_as_null` flag is left at its default value of ``False``, the ORM will now correctly insert the Json "'null'" string into the column whenever the value on the ORM object is set to the value ``None`` or when the value ``None`` is used with :meth:`.Session.bulk_insert_mappings`, **including** if the column has a default or server default on it. This makes use of a new type-level flag "evaluates_none" which is implemented by the JSON type based on the none_as_null flag. fixes #3514 - Added a new constant :attr:`.postgresql.JSON.NULL`, indicating that the JSON NULL value should be used for a value regardless of other settings. part of fixes #3514
* - add a warning suggesting to use the dictionary form of accessMike Bayer2015-07-051-0/+33
| | | | | | if the name of the attribute being accessed is non-specific, thereby avoiding collisions on names like items, values, keys. fixes #3475
* - Fixed a regression regarding the :meth:`.MapperEvents.instrument_class`Mike Bayer2015-04-261-5/+9
| | | | | | | | | | | | | | | | | 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
* - Fixed more regressions caused by NEVER_SET; comparisonsMike Bayer2015-04-201-5/+6
| | | | | | | | | 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
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - squash-merge the final row_proc integration branch. this isMike Bayer2015-03-011-0/+4
| | | | | | | | | | | | | | | a much more modest outcome than what we started with. The work of create_row_processor() for ColumnProperty objects is essentially done at query setup time combined with some lookups in _instance_processor(). - to allow this change for deferred columns, deferred columns no longer search for themselves in the result. If they've been set up as deferred without any explicit directive to undefer them, then this is what was asked for. if we don't do this, then we're stuck with this performance penalty for all deferred columns which in the vast majority of typical use cases (e.g. loading large, legacy tables or tables with many/large very seldom used values) won't be present in the result and won't be accessed at all.
* Merge branch 'bb_issue_3262' of https://bitbucket.org/xflr6/sqlalchemyMike Bayer2015-01-261-0/+9
|\
| * warn on duplicate polymorphic_identitySebastian Bank2014-12-041-0/+9
| |
* | - The "wildcard" loader options, in particular the one set up byMike Bayer2015-01-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | the :func:`.orm.load_only` option to cover all attributes not explicitly mentioned, now takes into account the superclasses of a given entity, if that entity is mapped with inheritance mapping, so that attribute names within the superclasses are also omitted from the load. Additionally, the polymorphic discriminator column is unconditionally included in the list, just in the same way that primary key columns are, so that even with load_only() set up, polymorphic loading of subtypes continues to function correctly. fixes #3287
* | - add MemoizedSlots, a generalized solution to using __getattr__Mike Bayer2015-01-051-0/+2
| | | | | | | | | | for memoization on a class that uses slots. - apply many more __slots__. mem use for nova now at 46% savings
* | - wip - start factoring events so that we aren't using descriptors for dispatch,Mike Bayer2015-01-041-2/+2
| | | | | | | | allowing us to move to __slots__
* | Merge branch 'master' into ticket_3100Mike Bayer2014-12-071-0/+2
|\ \ | |/
| * - Fixed a leak which would occur in the unsupported and highlyMike Bayer2014-11-131-0/+2
| | | | | | | | | | | | | | | | | | non-recommended use case of replacing a relationship on a fixed mapped class many times, referring to an arbitrarily growing number of target mappers. A warning is emitted when the old relationship is replaced, however if the mapping were already used for querying, the old relationship would still be referenced within some registries. fixes #3251
* | Merge branch 'master' into ticket_3100Mike Bayer2014-11-061-8/+13
|\ \ | |/
| * Merge remote-tracking branch 'origin/pr/140' into pr140Mike Bayer2014-10-111-1/+1
| |\
| | * cleanup exception handling - use new exception hierarchy (since python 2.5)pr/140ndparker2014-10-021-3/+1
| | |
| | * improve exception vs. exit handlingndparker2014-09-231-0/+2
| | |
| * | - add explicit warning re: polymorphic_on, cascading is not supportedMike Bayer2014-09-261-0/+6
| | | | | | | | | | | | at this time. ref #3214
| * | - refactor of declarative, break up into indiviudal methodsMike Bayer2014-09-251-7/+6
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge branch 'master' into ticket_3100Mike Bayer2014-09-021-16/+13
|\ \ | |/
| * - The :func:`~.expression.column` and :func:`~.expression.table`Mike Bayer2014-09-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | constructs are now importable from the "from sqlalchemy" namespace, just like every other Core construct. - The implicit conversion of strings to :func:`.text` constructs when passed to most builder methods of :func:`.select` as well as :class:`.Query` now emits a warning with just the plain string sent. The textual conversion still proceeds normally, however. The only method that accepts a string without a warning are the "label reference" methods like order_by(), group_by(); these functions will now at compile time attempt to resolve a single string argument to a column or label expression present in the selectable; if none is located, the expression still renders, but you get the warning again. The rationale here is that the implicit conversion from string to text is more unexpected than not these days, and it is better that the user send more direction to the Core / ORM when passing a raw string as to what direction should be taken. Core/ORM tutorials have been updated to go more in depth as to how text is handled. fixes #2992
| * - A new style of warning can be emitted which will "filter" up toMike Bayer2014-08-311-5/+4
| | | | | | | | | | | | | | | | | | N occurrences of a parameterized string. This allows parameterized warnings that can refer to their arguments to be delivered a fixed number of times until allowing Python warning filters to squelch them, and prevents memory from growing unbounded within Python's warning registries. fixes #3178
| * - major refactoring/inlining to loader.instances(), though not reallyMike Bayer2014-08-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | any speed improvements :(. code is in a much better place to be run into C, however - The ``proc()`` callable passed to the ``create_row_processor()`` method of custom :class:`.Bundle` classes now accepts only a single "row" argument. - Deprecated event hooks removed: ``populate_instance``, ``create_instance``, ``translate_row``, ``append_result`` - the getter() idea is somewhat restored; see ref #3175
| * - The "resurrect" ORM event has been removed. This event hook hadMike Bayer2014-08-251-11/+0
| | | | | | | | | | | | no purpose since the old "mutable attribute" system was removed in 0.8. fixes #3171
* | - rename mapper._primary_key_props to mapper._identity_key_propsMike Bayer2014-08-191-7/+11
| | | | | | | | - ensure bulk update is using all PK cols for all tables
* | Merge branch 'master' into ticket_3100Mike Bayer2014-08-191-0/+3
|\ \ | |/
| * - simplify PK logic in update for row switchMike Bayer2014-08-191-0/+3
| |
* | - refinementsMike Bayer2014-08-191-0/+4
|/
* - optimize collection of cols we insert as noneMike Bayer2014-08-181-9/+9
|
* - major simplification of _collect_update_commands. in particular,Mike Bayer2014-08-181-0/+13
| | | | | | we only call upon the history API fully for primary key columns. We also now skip the whole step of looking at PK columns and using any history at all if no net changes are detected on the object.
* - Fixed bug where attribute "set" events or columns withMike Bayer2014-08-171-10/+19
| | | | | | | | ``@validates`` would have events triggered within the flush process, when those columns were the targets of a "fetch and populate" operation, such as an autoincremented primary key, a Python side default, or a server-side default "eagerly" fetched via RETURNING. fixes #3167