Sfoglia il codice sorgente

Merge pull request #343 from tracim/fix/335/sorting_content_revisions

Damien Accorsi 6 anni fa
parent
commit
e5f0345572
1 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 9 1
      tracim/tracim/model/data.py

+ 9 - 1
tracim/tracim/model/data.py Vedi File

@@ -735,9 +735,17 @@ class Content(DeclarativeBase):
735 735
     revision_to_serialize = -0  # This flag allow to serialize a given revision if required by the user
736 736
 
737 737
     id = Column(Integer, primary_key=True)
738
+    # TODO - A.P - 2017-09-05 - revisions default sorting
739
+    # The only sorting that makes sens is ordering by "updated" field. But:
740
+    # - its content will soon replace the one of "created",
741
+    # - this "updated" field will then be dropped.
742
+    # So for now, we order by "revision_id" explicitly, but remember to switch
743
+    # to "created" once "updated" removed.
744
+    # https://github.com/tracim/tracim/issues/336
738 745
     revisions = relationship("ContentRevisionRO",
739 746
                              foreign_keys=[ContentRevisionRO.content_id],
740
-                             back_populates="node")
747
+                             back_populates="node",
748
+                             order_by="ContentRevisionRO.revision_id")
741 749
     children_revisions = relationship("ContentRevisionRO",
742 750
                                       foreign_keys=[ContentRevisionRO.parent_id],
743 751
                                       back_populates="parent")