fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
d86195c
)
fix for postgres
master
author
Radek Czajka
<rczajka@rczajka.pl>
Tue, 28 Jan 2025 12:53:20 +0000
(13:53 +0100)
committer
Radek Czajka
<rczajka@rczajka.pl>
Tue, 28 Jan 2025 12:53:20 +0000
(13:53 +0100)
src/documents/models/chunk.py
patch
|
blob
|
history
diff --git
a/src/documents/models/chunk.py
b/src/documents/models/chunk.py
index
4d8f6d2
..
797fc17
100644
(file)
--- a/
src/documents/models/chunk.py
+++ b/
src/documents/models/chunk.py
@@
-75,8
+75,10
@@
class Chunk(dvcs_models.Document):
def split(self, slug, title='', **kwargs):
""" Create an empty chunk after this one """
- self.book.chunk_set.filter(number__gt=self.number).update(
- number=models.F('number')+1)
+ # Single update makes unique constr choke on postgres.
+ for chunk in self.book.chunk_set.filter(number__gt=self.number).order_by('-number'):
+ chunk.number += 1
+ chunk.save()
new_chunk = None
while not new_chunk:
new_slug = self.book.make_chunk_slug(slug)