.switch() and .join_from() for CTE's
See original GitHub issueIt looks to me like the .switch()
and .join_from()
methods are only defined on the ModelSelect
class, meaning it’s impossible to join from a CTE to multiple other tables. It might be good to move the join context stuff up the class hierarchy to Select
, unless there’s some reason doing so would be tricky.
Is there a workaround for this? I could join starting from one of the other tables, but I think that can have bad performance implications. Maybe making a new CTE for each join would work.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Relationships and Joins — peewee 3.15.4 documentation
Note the call to switch() - that instructs Peewee to set the join context back ... CTE. .join_from(Tweet, User) # Join from tweet...
Read more >SQL Switch/Case in 'where' clause - Stack Overflow
I want the condition to exit because var IS equal to 0, but it goes ahead to check if it is numeric, which...
Read more >Subquery vs. CTE: A SQL Primer - LearnSQL.com
We've done this by using a subquery inside the FROM clause. Then, we simply use MAX() to return the largest average length. These...
Read more >Simplify your SQL Queries with Common Table Expressions ...
Simplify your SQL Queries with Common Table Expressions (CTEs) ... A CTE is a query whose result set you can reference in a...
Read more >CTEs in SQL Server; Querying Common Table Expressions
This article gives overview of a convenient way to query data Common Table Expressions(CTE) in SQL Server.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The join context only really has meaning for model-select, where peewee utilizes the structure of the model relationships to infer predicates and other things. A CTE can join multiple times, you just need to specify the appropriate predicate in the
on=
clause.It’s okay, I got my thing working. Thanks!