Here is the situation: I have a parent model BlogPost. He has a lot of Comments. I want the list to be BlogPostsorted by its creation date Comment. That is, a blog post that has the most recent comment should be at the top of the list. Is this possible with SQLAlchemy?
BlogPost
Comment
http://www.sqlalchemy.org/docs/05/mappers.html#controlling-ordering
Starting with version 0.5, ORM does not generate an order for any request unless explicitly configured." " , , order_by ():
Starting with version 0.5, ORM does not generate an order for any request unless explicitly configured.
" " , , order_by ():
, ORM, GHZ , . sqlalchemy, , BlogPost.comments , :
session.query(BlogPost).order_by (BlogPost.comments.creationDate.desc())
:
session.query(BlogPost).join().order_by (Comments.creationDate.desc())
Source: https://habr.com/ru/post/1702419/More articles:Случайные числа из базы данных - sqlDB connections in ASP.NET, MySQL and SQL Server - mysqlHow to determine the Java runtime set on the client from an ASP.NET website? - javauploaded files - database and file system, using Grails and MySQL - mysqlCan I use applications using Java 1.4.2_12 and Java 1.5 on the same Windows server? - java[DBNETLIB] [ConnectionOpen (SECDoClientHandshake ()).] SSL Security Error - iisImport dll Eclipse C ++ - c ++Is Microsoft Sync Services a good solution for me? - designhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1702423/how-do-i-use-ctypes-to-set-a-librarys-extern-function-pointer-to-a-python-callback-function&usg=ALkJrhiIokAu5h2kgBmGIjTarXx1DBdX6gChoosing a PHP Framework for long-term deployment - phpAll Articles