You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,26 +2,39 @@
2
2
3
3
## [Unreleased]
4
4
5
+
## [3.0.1] - 2020-08-05
6
+
7
+
### Updated
8
+
9
+
- Transactions now support models routed to different databases.
10
+
5
11
## [3.0.0] - 2020-07-28
12
+
6
13
### Changed
7
-
-**Potentially breaking change** Retain PK if provided and ensure a crash if it mismatches on key_field. #10
8
14
9
-
If your input models have the PK set already and expect it to be cleared by bulk_sync, that won't happen anymore.
10
-
Please clear the pks yourself if you want them to seem like "new" objects.
15
+
-**Potentially breaking change** Retain PK if provided and ensure a crash if it mismatches on key_field. #10
16
+
17
+
If your input models have the PK set already and expect it to be cleared by bulk_sync, that won't happen anymore.
18
+
Please clear the pks yourself if you want them to seem like "new" objects.
11
19
12
20
## [2.1.0] - 2020-06-05
21
+
13
22
### Added
14
-
- Added support for skip_deletes, skip_creates, and skip_updates in bulk_sync method. #9, pull request from [@mikefreemanwd](https://github.com/mikefreemanwd).
23
+
24
+
- Added support for skip_deletes, skip_creates, and skip_updates in bulk_sync method. #9, pull request from [@mikefreemanwd](https://github.com/mikefreemanwd).
15
25
16
26
### Updated
17
-
- Updated stats returned by bulk_sync to reflect what actually happened given the flags rather than what would have happend if all flags are false.
27
+
28
+
- Updated stats returned by bulk_sync to reflect what actually happened given the flags rather than what would have happend if all flags are false.
18
29
19
30
## [2.0.0] - 2020-05-19
31
+
20
32
### Removed
21
-
- Removed support for Django versions before 2.2. Please use 1.x series for Django < 2.2.
22
33
34
+
- Removed support for Django versions before 2.2. Please use 1.x series for Django < 2.2.
Combine bulk create, update, and delete. Make the DB match a set of in-memory objects.
67
71
68
72
-`new_models`: An iterable of Django ORM `Model` objects that you want stored in the database. They may or may not have `id` set, but you should not have already called `save()` on them.
69
-
-`key_fields`: Identifying attribute name(s) to match up `new_models` items with database rows. If a foreign key is being used as a key field, be sure to pass the `fieldname_id` rather than the `fieldname`.
73
+
-`key_fields`: Identifying attribute name(s) to match up `new_models` items with database rows. If a foreign key is being used as a key field, be sure to pass the `fieldname_id` rather than the `fieldname`. Use `['pk']` if you know the PKs already and want to use them to identify and match up `new_models` with existing database rows.
70
74
-`filters`: Q() filters specifying the subset of the database to work in. Use `None` or `[]` if you want to sync against the entire table.
71
-
-`batch_size`: passes through to Django `bulk_create.batch_size` and `bulk_update.batch_size`, and controls how many objects are created/updated per SQL query.
75
+
-`batch_size`: (optional) passes through to Django `bulk_create.batch_size` and `bulk_update.batch_size`, and controls how many objects are created/updated per SQL query.
72
76
-`fields`: (optional) List of fields to update. If not set, will sync all fields that are editable and not auto-created.
73
-
-`skip_creates`: If truthy, will not perform any object creations needed to fully sync. Defaults to not skip.
74
-
-`skip_updates`: If truthy, will not perform any object updates needed to fully sync. Defaults to not skip.
75
-
-`skip_deletes`: If truthy, will not perform any object deletions needed to fully sync. Defaults to not skip.
77
+
-`skip_creates`: (optional) If truthy, will not perform any object creations needed to fully sync. Defaults to not skip.
78
+
-`skip_updates`: (optional) If truthy, will not perform any object updates needed to fully sync. Defaults to not skip.
79
+
-`skip_deletes`: (optional) If truthy, will not perform any object deletions needed to fully sync. Defaults to not skip.
76
80
77
81
- Returns a dict:
78
-
82
+
```
79
83
{
80
84
'stats': {
81
-
"created": number of `new_models` not found in database and so created,
82
-
"updated": number of `new_models` that were found in database as matched by `key_fields`,
83
-
"deleted": number of deleted objects - rows in database that matched `filters` but were not present in `new_models`.
84
-
}
85
+
"created": number of `new_models` not found in database and so created,
86
+
"updated": number of `new_models` that were found in database as matched by `key_fields`,
87
+
"deleted": number of deleted objects - rows in database that matched `filters` but were not present in `new_models`.
@@ -92,7 +97,16 @@ Compare two sets of models by `key_fields`.
92
97
- `key_fields`: Identifying attribute name(s) to match up `new_models` items with database rows. If a foreign key
93
98
is being used as a key field, be sure to pass the `fieldname_id` rather than the `fieldname`.
94
99
- `ignore_fields`: (optional) If set, provide field names that should not be considered when comparing objects.
95
-
- Returns dict of: `{ 'added': list of all added objects. 'unchanged': list of all unchanged objects. 'updated': list of all updated objects. 'updated_details': dict of {obj: {field_name: (old_value, new_value)}} for all changed fields in each updated object. 'removed': list of all removed objects. }`
100
+
- Returns dict:
101
+
```
102
+
{
103
+
'added': list of all added objects.
104
+
'unchanged': list of all unchanged objects.
105
+
'updated': list of all updated objects.
106
+
'updated_details': dict of {obj: {field_name: (old_value, new_value)}} for all changed fields in each updated object.
0 commit comments