Querying with two consecutive WITH causes error "the table is not part of the query"
I created my query by stages. I create a part, check it's result via await and .all() then I turn it to CTE ($with) and use in from() of the next stage.
The first part (screenshot 1)
1. Worked well via direct await
2. Worked well when turned into $with and used in .from() of next stage
The second part (screenshot 2)
1. Worked well via direct await
2. Stops working when I use it in .from() of the next stage (screenshot 3), outputs an error:
In 3rd stage you see me trying to fix it by manually adding fields to select after seeing such tip here in discord under question with similar error. I think error is not in second or first screenshot since everything works fine until I turn second stage to CTE too and try to use in in next stage.
Dialect is SQLite (libSQL).
@bloberenober Can this be a bug in QB in code that is detecting for this error?



1 Reply
bumping for @bloberenober to answer