1

I'm defining a relationship in my class and I need to apply a nullslast to the order_by. How would I do this in the relationship or is there another way to go about it?

flags = relationship("Flag",
    backref=backref("box", lazy="select"),
    cascade="all,delete,delete-orphan", order_by="Flag._order",
    )
SuperShoot
  • 9,880
  • 2
  • 38
  • 55
ElJeffe
  • 637
  • 1
  • 8
  • 20

1 Answers1

1

I was able to get what I wanted by following this advice and making the order_by negative with a desc. Hope it works with more than mysql.

flags = relationship("Flag",
    backref=backref("box", lazy="select"),
    cascade="all,delete,delete-orphan", order_by="desc(-Flag._order)",
    )
ElJeffe
  • 637
  • 1
  • 8
  • 20