I woudln't consider it as an actual 'fix' though.

ср, 18 июл. 2018 г. в 18:17, n.pettik@corp.mail.ru <n.pettik@corp.mail.ru>:

I tried to test that problem on this sqlite3 version with -DSQLITE_DEBUG and assertion fails there. 
Since flattening only makes another compound select-stmt with ORDER BY clause I guess error was
occuring on flattened version of it. Moreover in latter versions of sqlite3 this assert was deleted and the
restriction check wasn't fixed. So I assume sqlite3 developers just don't know about it or don't aim on
fixing it as the error anyways occurs but on flattened subquery.

Here is original fix of this assertion fail (JFYI):
https://www.sqlite.org/src/info/823779d31eb09cda