From 9423ab7f075afd3e1501a2d1438fc8330811e40e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 21 Jan 2017 19:00:45 -0500 Subject: Fixed statement generation involving negative subqueries Previously, we generated negative subqueries by integrating them into the main statement normally, and then making the connecting join be a LEFT JOIN instead of an INNER JOIN, and by adding a condition that the join column be NULL. The problem with this is that if the top table of the subquery joins against any other table (which join throughs always do), then no rows will be returned. This was solved by putting the subquery into a CTE and then LEFT JOINing as before with the CTE. --- lib/statement.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib/statement.h') diff --git a/lib/statement.h b/lib/statement.h index a528d60..8188ec0 100644 --- a/lib/statement.h +++ b/lib/statement.h @@ -184,13 +184,15 @@ namespace verbly { std::map tables, std::string topTable, condition where, - std::list joins) : + std::list joins, + bool recursive) : identifier_(std::move(identifier)), field_(f), tables_(std::move(tables)), topTable_(std::move(topTable)), topCondition_(std::move(where)), - joins_(std::move(joins)) + joins_(std::move(joins)), + recursive_(recursive) { } @@ -224,6 +226,11 @@ namespace verbly { return joins_; } + bool isRecursive() const + { + return recursive_; + } + private: std::string identifier_; field field_; @@ -231,6 +238,7 @@ namespace verbly { std::string topTable_; condition topCondition_; std::list joins_; + bool recursive_; }; @@ -254,7 +262,9 @@ namespace verbly { std::string instantiateTable(std::string name); - condition integrate(statement subStmt); + std::string instantiateWith(std::string name); + + condition integrate(statement subStmt, bool cte = false); int nextTableId_; int nextWithId_; -- cgit 1.4.1