tschilling
c5808470aa
Fixed #34280 -- Allowed specifying different field values for create operation in QuerySet.update_or_create().
2023-02-14 11:50:35 +01:00
David Smith
097e3a70c1
Refs #33476 -- Applied Black's 2023 stable style.
...
Black 23.1.0 is released which, as the first release of the year,
introduces the 2023 stable style. This incorporates most of last year's
preview style.
https://github.com/psf/black/releases/tag/23.1.0
2023-02-01 11:04:38 +01:00
Msvstl
67bc2f1b99
Corrected test_update_or_create_with_model_property_defaults test.
2022-10-29 13:27:10 +02:00
sarahboyce
6cc0f22a73
Fixed #32095 -- Made QuerySet.update_or_create() save only fields passed in defaults or with custom pre_save().
...
Thanks Florian Apolloner for the initial patch.
2022-09-30 06:26:19 +02:00
sarahboyce
ae3d575ec3
Added tests for QuerySet.update_or_create() with multi-table inheritance.
2022-09-27 12:55:33 +02:00
Mariusz Felisiak
7119f40c98
Refs #33476 -- Refactored code to strictly match 88 characters line length.
2022-02-07 20:37:05 +01:00
django-bot
9c19aff7c7
Refs #33476 -- Reformatted code with Black.
2022-02-07 20:37:05 +01:00
Simon Charette
84e7a9f4a7
Switched setUp() to setUpTestData() where possible in Django's tests.
2018-11-27 09:35:17 -05:00
Michael Sanders
271542dad1
Fixed #29499 -- Fixed race condition in QuerySet.update_or_create().
...
A race condition happened when the object didn't already exist and
another process/thread created the object before update_or_create()
did and then attempted to update the object, also before update_or_create()
saved the object. The update by the other process/thread could be lost.
2018-08-02 17:07:48 -04:00
Viktor Danyliuk
6ae7aaa7d6
Fixed #29413 -- Prevented evaluation of QuerySet.get_or_create()/update_or_create() defaults unless needed.
...
Removed the logic added in 81e05a418d
which
was obsolete since dbffffa7dc
.
2018-07-16 22:08:43 -04:00
Tim Graham
e917ea6bec
Fixed #29126 -- Doc'd the behavior of QuerySet.update_or_create() with manually specified pks.
2018-02-15 13:17:37 -05:00
Alex
37ab3c3f9d
Fixed #28222 -- Allowed settable properties in QuerySet.update_or_create()/get_or_create() defaults.
2017-05-27 12:41:38 -04:00
Jon Dufresne
b39aabc6c6
Refs #27795 -- Reworked get_or_create test erroneously mixing bytes and str.
...
As CharField.to_python() now always calls str(), assigning bytes to a
CharField is no longer correct usage. Doing so results in a warning:
django/db/models/fields/__init__.py:1061: BytesWarning: str() on a bytes instance
Use a unique constraint violation to trigger the database error instead.
Warning introduced in 301de774c2
.
2017-05-01 08:47:49 -04:00
Claude Paroz
042b7350a0
Refs #23919 -- Removed unneeded str() calls
2017-01-20 14:13:55 +01:00
Claude Paroz
d7b9aaa366
Refs #23919 -- Removed encoding preambles and future imports
2017-01-18 09:55:19 +01:00
François Freitag
1db1f74617
Refs #27118 -- Reallowed using pk in QuerySet.get/update_or_create().
2016-10-04 10:10:39 -04:00
Sergey Fursov
6709ea4ae9
Fixed #27271 -- Fixed a crash in runserver logging.
...
Allowed ServerFormatter to handle simple string messages or messages with
formatting arguments. The formatter will set the server_time variable on
the log record if it's required by the format string but wasn't passed in
extra parameters.
2016-09-27 09:46:07 -04:00
François Freitag
a5e13a0b92
Fixed #27118 -- Made QuerySet.get_or_create()/update_or_create() error for a non-field in their arguments.
2016-09-24 20:16:16 -04:00
Jensen Cochran
83be40760a
Fixed #26933 -- Fixed flaky update_or_create() test from refs #26804 .
2016-07-28 21:45:35 -04:00
Jensen Cochran
d44afd8892
Fixed #26804 -- Fixed a race condition in QuerySet.update_or_create().
2016-07-14 12:10:19 -04:00
Kenneth
841cb45847
Fixed #26884 -- Evaluated callables in QuerySet.update_or_create()'s defaults when updating.
2016-07-12 22:09:53 -04:00
Tim Graham
c9ae09addf
Replaced use of TestCase.fail() with assertRaises().
...
Also removed try/except/fail antipattern that hides exceptions.
2016-06-28 11:21:26 -04:00
Will Koster
9899347641
Fixed #26638 -- Allowed callable arguments for QuerySet.get_or_create()/update_or_create() defaults.
2016-06-03 10:00:53 -04:00
Hasan
3d0dcd7f5a
Refs #26022 -- Used context manager version of assertRaises in tests.
2016-01-29 12:32:18 -05:00
Andriy Sokolovskiy
fc19f9315b
Refs #22728 - Added missing tests for defaults__exact case
2015-06-05 09:22:49 +01:00
Tim Graham
0ed7d15563
Sorted imports with isort; refs #23860 .
2015-02-06 08:16:28 -05:00
Claude Paroz
51890ce889
Applied ignore_warnings to Django tests
2014-12-30 18:16:25 +01:00
Loic Bistuer
0eccf8fbea
Fixed misplaced test case.
2014-10-08 05:11:09 +07:00
Loic Bistuer
ed37f7e979
Fixed #23611 -- update_or_create failing from a related manager
...
Added update_or_create to RelatedManager, ManyRelatedManager and
GenericRelatedObjectManager.
Added missing get_or_create to GenericRelatedObjectManager.
2014-10-08 03:27:31 +07:00
Aymeric Augustin
25b2ce896b
Consolidated get_or_create tests.
2014-04-21 12:12:09 +02:00
Simon Charette
79f05616fb
Fixed flake8 warnings introduced in recent commits.
2014-04-16 16:49:37 -04:00
Liav Koren
9b29a551e4
Refs #18586 - Refactored model get_or_create test.
...
Refactored get_or_create test into several smaller test functions across two
different test classes. Also converted the comments over to docstrings.
2014-04-14 18:19:37 -04:00
Loic Bistuer
a2814846ca
Fixed E124 pep8 warnings.
2013-12-10 15:12:48 -05:00
Tim Graham
96d1d4e292
Removed unused local variables in tests.
2013-10-19 08:31:38 -04:00
Aymeric Augustin
e6c0020d19
Translated a test to English for consistency.
...
Also fixed a typo.
2013-09-22 22:48:22 +02:00
Claude Paroz
5c1143910e
Removed most of absolute_import imports
...
Should be unneeded with Python 2.7 and up.
Added some unicode_literals along the way.
2013-07-29 20:28:13 +02:00
Karol Sikora
6272d2f155
Fixed #20429 -- Added QuerySet.update_or_create
...
Thanks tunixman for the suggestion and Loic Bistuer for the review.
2013-07-12 08:26:35 -04:00
Aymeric Augustin
c6e6d4eeb7
Defined available_apps in relevant tests.
...
Fixed #20483 .
2013-06-10 11:30:01 +02:00
Tim Graham
90af278203
Fixed #16137 - Removed kwargs requirement for QuerySet.get_or_create
...
Thanks wilfred@, poirier, and charettes for work
on the patch.
2013-05-27 10:01:14 -04:00
Shai Berger
36d47f72e3
Fixed get_or_create...test_savepoint_rollback test for Python3
...
The test was always skipped on Python3 because string literals are unicode
2013-05-26 01:53:24 +03:00
Shai Berger
cf159e5c93
Fix get_or_create test failure under Oracle
...
Test expected that when given invalid utf-8, the backend should raise
a DatabaseError, but the Oracle backend raises a UnicodeDecodeError.
2013-05-26 01:39:34 +03:00
Aymeric Augustin
0e51d8eb66
Fixed #20463 -- Made get_or_create more robust.
...
When an exception other than IntegrityError was raised, get_or_create
could fail and leave the database connection in an unusable state.
Thanks UloPe for the report.
2013-05-22 10:56:06 +02:00
Pablo Recio
65f9e0affd
Fixes #18896 . Add tests verifying that you can get IntegrityErrors using get_or_create through relations like M2M, and it also adds a note into the documentation warning about it
2013-05-19 14:16:12 +02:00
Aymeric Augustin
3a4276ffc3
Tested that get_or_create raises IntegrityError.
...
It used to raise "DatabaseError: no such savepoint" with the old
transaction management. Closes #15117 .
2013-04-28 17:15:41 +02:00
Florian Apolloner
89f40e3624
Merged regressiontests and modeltests into the test root.
2013-02-26 14:36:57 +01:00