summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/persistence.py
Commit message (Collapse)AuthorAgeFilesLines
* - merge of ticket_3514 None-handling branchMike Bayer2015-08-171-1/+3
| | | | | | | | | | | | | | | | - 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
* - Fixed 1.0 regression where value objects that overrideMike Bayer2015-07-011-2/+4
| | | | | | | | | ``__eq__()`` to return a non-boolean-capable object, such as some geoalchemy types as well as numpy types, were being tested for ``bool()`` during a unit of work update operation, where in 0.9 the return value of ``__eq__()`` was tested against "is True" to guard against this. fixes #3469
* - Fixed a major regression in the 1.0 series where the version_id_counterMike Bayer2015-06-241-1/+18
| | | | | | | | | | | | | feature would cause an object's version counter to be incremented when there was no net change to the object's row, but instead an object related to it via relationship (e.g. typically many-to-one) were associated or de-associated with it, resulting in an UPDATE statement that updates the object's version counter and nothing else. In the use case where the relatively recent "server side" and/or "programmatic/conditional" version counter feature were used (e.g. setting version_id_generator to False), the bug could cause an UPDATE without a valid SET clause to be emitted. fixes #3465
* - restore the approach we have for pk_params, but in orderMike Bayer2015-06-131-6/+8
| | | | | to suit #3451 exclude these columns from the "params" dictionary in the first place, revises pr github:181
* Fix primary key behaviour in bulk_updatepr/181Patrick Hayes2015-06-131-6/+5
| | | | | | | | | | | | | | | | | | | | | | | Suppose you have a model class with a primary key. Base = declarative_base() class User(Base): id = Column(BigInteger, primary_key=True) name = Column(String) Previously, running `bulk_update_mappings(User, {'id': 1, 'name': 'hello'})` would emit the following: ```UPDATE users SET id=1, name='hello' WHERE id=1``` This is contrary to the stated behaviour, where primary keys are omitted from the SET clause. Furthermore, this behaviour is harmful, as it can cause the db engine to lock over-aggresively (at least in Postgres). With this change, the emitted SQL is: ```UPDATE users SET name='hello' WHERE id=1```
* - Fixed regression in the :mod:`sqlalchemy.ext.mutable` extensionMike Bayer2015-05-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | as a result of the bugfix for :ticket:`3167`, where attribute and validation events are no longer called within the flush process. The mutable extension was relying upon this behavior in the case where a column level Python-side default were responsible for generating the new value on INSERT or UPDATE, or when a value were fetched from the RETURNING clause for "eager defaults" mode. The new value would not be subject to any event when populated and the mutable extension could not establish proper coercion or history listening. A new event :meth:`.InstanceEvents.refresh_flush` is added which the mutable extension now makes use of for this use case. fixes #3427 - Added new event :meth:`.InstanceEvents.refresh_flush`, invoked when an INSERT or UPDATE level default value fetched via RETURNING or Python-side default is invoked within the flush process. This is to provide a hook that is no longer present as a result of :ticket:`3167`, where attribute and validation events are no longer called within the flush process. - Added a new semi-public method to :class:`.MutableBase` :meth:`.MutableBase._get_listen_keys`. Overriding this method is needed in the case where a :class:`.MutableBase` subclass needs events to propagate for attribute keys other than the key to which the mutable type is associated with, when intercepting the :meth:`.InstanceEvents.refresh` or :meth:`.InstanceEvents.refresh_flush` events. The current example of this is composites using :class:`.MutableComposite`.
* - Fixed regression from 0.9.10 prior to release due to :ticket:`3349`Mike Bayer2015-04-301-8/+8
| | | | | | | | where the check for query state on :meth:`.Query.update` or :meth:`.Query.delete` compared the empty tuple to itself using ``is``, which fails on Pypy to produce ``True`` in this case; this would erronously emit a warning in 0.9 and raise an exception in 1.0. fixes #3405
* - Fixed regression within the flush process when an attribute wereMike Bayer2015-04-291-5/+4
| | | | | | | | | set to a SQL expression for an UPDATE, and the SQL expression when compared to the previous value of the attribute would produce a SQL comparison other than ``==`` or ``!=``, the exception "Boolean value of this clause is not defined" would raise. The fix ensures that the unit of work will not interpret the SQL expression in this way. fixes #3402
* - Fixed more regressions caused by NEVER_SET; comparisonsMike Bayer2015-04-201-1/+1
| | | | | | | | | 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
* Merge remote-tracking branch 'origin/pr/164' into pr164Mike Bayer2015-04-031-4/+6
|\
| * Allow kwargs to be passed through update()pr/164Amir Sadoughi2015-03-201-4/+6
| | | | | | | | | | This is useful to be able to pass in mysql_limit=1 from using the ORM.
* | - :class:`.Query` doesn't support joins, subselects, or specialMike Bayer2015-04-011-10/+46
|/ | | | | | | | | | | | | | | FROM clauses when using the :meth:`.Query.update` or :meth:`.Query.delete` methods; instead of silently ignoring these fields if methods like :meth:`.Query.join` or :meth:`.Query.select_from` has been called, an error is raised. In 0.9.10 this only emits a warning. fixes #3349 - don't needlessly call _compile_context() and build up a whole statement that we never need. Construct QueryContext as it's part of the event contract, but don't actually call upon mapper attributes; use more direct systems of determining the update or delete table. - don't realy need _no_select_modifiers anymore
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - restore r611883ffb35ca6664649f6328ae8 with additional fixes and an ↵Mike Bayer2015-01-191-4/+8
| | | | | | additional test that is much more specific to #1326
* - reverse the last commit temporarily as it breaks all the polymorphic casesMike Bayer2015-01-191-8/+4
|
* - The primary :class:`.Mapper` of a :class:`.Query` is now passed to theMike Bayer2015-01-191-4/+8
| | | | | | | | | | | :meth:`.Session.get_bind` method when calling upon :meth:`.Query.count`, :meth:`.Query.update`, :meth:`.Query.delete`, as well as queries against mapped columns, :obj:`.column_property` objects, and SQL functions and expressions derived from mapped columns. This allows sessions that rely upon either customized :meth:`.Session.get_bind` schemes or "bound" metadata to work in all relevant cases. fixes #3227 fixes #3242 fixes #1326
* - further fixes and even better tests for this blockMike Bayer2015-01-191-3/+8
|
* - another adjustmentMike Bayer2015-01-191-2/+3
|
* - fix another issue from rf49c367ef, add another testMike Bayer2015-01-181-1/+1
|
* - fix a regression from ref #3178, where dialects that don't actually supportMike Bayer2015-01-171-4/+12
| | | | | sane multi rowcount (e.g. pyodbc) would fail on multirow update. add a test that mocks this breakage into plain dialects
* - add an option for bulk_save -> update to not do historyMike Bayer2014-12-071-2/+7
|
* - fix inheritance persistenceMike Bayer2014-12-071-6/+9
| | | | - start writing docs
* Merge branch 'master' into ticket_3100Mike Bayer2014-11-061-4/+4
|\ | | | | | | | | Conflicts: lib/sqlalchemy/orm/persistence.py
| * Small improvement on FlushError can't update error messagepr/149Paulo Bu2014-11-061-4/+4
| | | | | | | | Output in the error message the table name and the column name.
* | Merge branch 'master' into ticket_3100Mike Bayer2014-11-061-7/+40
|\ \ | |/
| * Small improvement on FlushError can't delete error messagepr/148Paulo Bu2014-11-051-2/+2
| | | | | | | | Output in the error message the table name and the column name.
| * - The :meth:`.Query.update` method will now convert string keyMike Bayer2014-10-161-5/+38
| | | | | | | | | | | | | | | | | | | | names in the given dictionary of values into mapped attribute names against the mapped class being updated. Previously, string names were taken in directly and passed to the core update statement without any means to resolve against the mapped entity. Support for synonyms and hybrid attributes as the subject attributes of :meth:`.Query.update` are also supported. fixes #3228
* | Merge branch 'master' into ticket_3100Mike Bayer2014-09-051-3/+3
|\ \ | |/
| * - tiny refactors #1-#5Mike Bayer2014-09-051-3/+3
| |
* | - add options to get back pk defaults for inserts.Mike Bayer2014-09-021-11/+26
| | | | | | | | times spent start getting barely different...
* | Merge branch 'master' into ticket_3100Mike Bayer2014-09-021-2/+1
|\ \ | |/
| * - A new style of warning can be emitted which will "filter" up toMike Bayer2014-08-311-2/+1
| | | | | | | | | | | | | | | | | | 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
* | - that's it, feature is finished, needs testsMike Bayer2014-08-201-106/+89
| |
* | Merge branch 'master' into ticket_3100Mike Bayer2014-08-201-55/+55
|\ \ | |/
| * - factor out determination of current version id out ofMike Bayer2014-08-201-55/+55
| | | | | | | | _collect_update_commands and _collect_delete_commands
* | Merge branch 'master' into ticket_3100Mike Bayer2014-08-191-16/+6
|\ \ | |/
| * - simplify PK logic in update for row switchMike Bayer2014-08-191-16/+6
| |
* | - refinementsMike Bayer2014-08-191-35/+72
| |
* | devMike Bayer2014-08-181-19/+18
| |
* | devMike Bayer2014-08-181-26/+21
| |
* | Merge branch 'master' into ticket_3100Mike Bayer2014-08-181-210/+212
|\ \ | |/ | | | | | | | | Conflicts: lib/sqlalchemy/orm/mapper.py lib/sqlalchemy/orm/persistence.py
| * - optimize collection of cols we insert as noneMike Bayer2014-08-181-8/+2
| |
| * - move out checks for table in mapper._pks_by_tableMike Bayer2014-08-181-16/+32
| |
| * - further reorganize collect_insert_commands to distinguish betweenMike Bayer2014-08-181-13/+21
| | | | | | | | | | setting up given values vs. defaults. again trying to shoot for making this of more general use
| * - organize persistence methods in terms of generators,Mike Bayer2014-08-181-93/+94
| | | | | | | | | | | | narrow down argument lists and generator items for each function down to just what each function needs. This will help for them to be of more multipurpose use for bulk operations
| * - major simplification of _collect_update_commands. in particular,Mike Bayer2014-08-181-83/+57
| | | | | | | | | | | | 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-9/+3
| | | | | | | | | | | | | | | | ``@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
| * - support dialects w/o sane multi row count againMike Bayer2014-08-161-15/+33
| |
| * - port the _collect_insert_commands optimizations from ticket_3100Mike Bayer2014-08-151-36/+35
| |
* | - refine this enough so that _collect_insert_commands() seemsMike Bayer2014-08-151-133/+126
| | | | | | | | | | | | | | | | to be more than twice as fast now (.039 vs. .091); bulk_insert() and bulk_update() do their own collection but now both call into _emit_insert_statements() / _emit_update_statements(); the approach seems to have no impact on insert speed, still .85 for the insert test