summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/mapper.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
* - port the _collect_insert_commands optimizations from ticket_3100Mike Bayer2014-08-151-0/+35
|
* - rename _InspectionAttr to InspectionAttrMike Bayer2014-08-131-5/+5
|
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-258/+267
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - Additional checks have been added for the case where an inheritingMike Bayer2014-06-201-7/+16
| | | | | | | | | | 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 :ticket:`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
* - Adjustment to attribute mechanics concerning when a value isMike Bayer2014-05-291-7/+9
| | | | | | | | | | | | | | implicitly initialized to None via first access; this action, which has always resulted in a population of the attribute, now emits an attribute event just like any other attribute set operation and generates the same kind of history as one. Additionally, many mapper internal operations will no longer implicitly generate these "None" values when various never-set attributes are checked. These are subtle behavioral fixes to attribute mechanics which provide a better solution to the problem of :ticket:`3060`, which also involves recognition of attributes explicitly set to ``None`` vs. attributes that were never set. fixes #3061
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-4/+4
| | | | Found using: https://github.com/intgr/topy
* - Added new parameter :paramref:`.mapper.confirm_deleted_rows`. DefaultsMike Bayer2014-03-281-1/+17
| | | | | | | | | | | | to True, indicates that a series of DELETE statements should confirm that the cursor rowcount matches the number of primary keys that should have matched; this behavior had been taken off in most cases (except when version_id is used) to support the unusual edge case of self-referential ON DELETE CASCADE; to accomodate this, the message is now just a warning, not an exception, and the flag can be used to indicate a mapping that expects self-refererntial cascaded deletes of this nature. See also :ticket:`2403` for background on the original change. re: #2403 fix #3007
* - add cross-linking for passive_deletes / passive_updatesMike Bayer2014-02-161-2/+2
|
* - Fixed bug where :class:`.AbstractConcreteBase` would fail to beMike Bayer2014-02-111-4/+3
| | | | | | | | | | | | | | | | | | | | | fully usable within declarative relationship configuration, as its string classname would not be available in the registry of classnames at mapper configuration time. The class now explicitly adds itself to the class regsitry, and additionally both :class:`.AbstractConcreteBase` as well as :class:`.ConcreteBase` set themselves up *before* mappers are configured within the :func:`.configure_mappers` setup, using the new :meth:`.MapperEvents.before_configured` event. [ticket:2950] - Added new :meth:`.MapperEvents.before_configured` event which allows an event at the start of :func:`.configure_mappers`, as well as ``__declare_first__()`` hook within declarative to complement ``__declare_last__()``. - modified how after_configured is invoked; we just make a dispatch() not actually connected to any mapper. this makes it easier to also invoke before_configured correctly. - improved the ComparableEntity fixture to handle collections that are sets.