File tree 2 files changed +51
-1
lines changed
2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 1
1
Changes
2
2
=======
3
3
4
+ 1.18.0
5
+ ------
6
+
7
+ ``update_self ``
8
+ ~~~~~~~~~~~~~~~
9
+
10
+ Added the ``update_self `` method, which is an alternative to the ``save ``
11
+ method. Here's an example where it's useful:
12
+
13
+ .. code-block :: python
14
+
15
+ # If we have a band object:
16
+ >> > band = Band.objects().get(name = " Pythonistas" )
17
+ >> > band.popularity
18
+ 1000
19
+
20
+ # We can increment the popularity, based on the current value in the
21
+ # database:
22
+ >> > await band.update_self({
23
+ ... Band.popularity: Band.popularity + 1
24
+ ... })
25
+
26
+ # The new value is set on the object:
27
+ >> > band.popularity
28
+ 1001
29
+
30
+ # It's safer than using the `save` method, because the popularity value on
31
+ # the object might be out of date with what's in the database:
32
+ band.popularity += 1
33
+ await band.save()
34
+
35
+ Thanks to @trondhindenes for suggesting this feature.
36
+
37
+ Batch raw queries
38
+ ~~~~~~~~~~~~~~~~~
39
+
40
+ The ``batch `` method can now be used with ``raw `` queries. For example:
41
+
42
+ .. code-block :: python
43
+
44
+ async with await MyTable.raw(" SELECT * FROM my_table" ).batch() as batch:
45
+ async for _batch in batch:
46
+ print (_batch)
47
+
48
+ This is useful when you expect a raw query to return a lot of data.
49
+
50
+ Thanks to @devsarvesh92 for suggesting this feature.
51
+
52
+ -------------------------------------------------------------------------------
53
+
4
54
1.17.1
5
55
------
6
56
Original file line number Diff line number Diff line change 1
- __VERSION__ = "1.17.1 "
1
+ __VERSION__ = "1.18.0 "
You can’t perform that action at this time.
0 commit comments