Skip to content
Advertisement

Create subquery using peewee, using `.select` on the subquery results

I have a rather complex peewee query that looks like that:

This one actually works, generating the following SQL query:

But I don’t really want to use RIGHT_JOIN as it isn’t supported by SQLite.

When trying to query using the subquery query and JOINing the Solution table into the subquery’s result, I get an error from peewee.

The new query:

The generated query:

Which results in:

Why does peewee flatten the query? Is there another way to use LEFT_JOIN?

Advertisement

Answer

Eventually found the Select function in the documentation, which allows me to kind of wrap the previous query:

This solution works.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement