diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/statement.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
| diff --git a/lib/statement.cpp b/lib/statement.cpp index b892cab..e84a402 100644 --- a/lib/statement.cpp +++ b/lib/statement.cpp | |||
| @@ -309,6 +309,11 @@ namespace verbly { | |||
| 309 | joinCondition &= (field::integerField(joinTableName.c_str(), clause.getField().getConditionColumn()) == clause.getField().getConditionValue()); | 309 | joinCondition &= (field::integerField(joinTableName.c_str(), clause.getField().getConditionColumn()) == clause.getField().getConditionValue()); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | // Instantiate a CTE in case we need one. This is necessary because | ||
| 313 | // the nextWithId is propagated in the instantiation of the joinStmt | ||
| 314 | // below. | ||
| 315 | std::string withName = instantiateWith(joinTableName); | ||
| 316 | |||
| 312 | // Recursively parse the subquery, and therefore obtain an | 317 | // Recursively parse the subquery, and therefore obtain an |
| 313 | // instantiated table to join against, as well as any joins or CTEs | 318 | // instantiated table to join against, as well as any joins or CTEs |
| 314 | // that the subquery may require to function. | 319 | // that the subquery may require to function. |
| @@ -331,7 +336,6 @@ namespace verbly { | |||
| 331 | // will return zero results. Instead, we create a non-recursive | 336 | // will return zero results. Instead, we create a non-recursive |
| 332 | // CTE that represents the subquery, then LEFT JOIN against it and | 337 | // CTE that represents the subquery, then LEFT JOIN against it and |
| 333 | // condition on the join column being NULL as before. | 338 | // condition on the join column being NULL as before. |
| 334 | std::string withName = instantiateWith(joinTableName); | ||
| 335 | std::string withInstName = instantiateTable(withName); | 339 | std::string withInstName = instantiateTable(withName); |
| 336 | 340 | ||
| 337 | // LEFT JOIN against the CTE. | 341 | // LEFT JOIN against the CTE. |
| @@ -383,6 +387,11 @@ namespace verbly { | |||
| 383 | case field::type::join_through: | 387 | case field::type::join_through: |
| 384 | case field::type::join_through_where: | 388 | case field::type::join_through_where: |
| 385 | { | 389 | { |
| 390 | // Instantiate a CTE in case we need one. This is necessary because | ||
| 391 | // the nextWithId is propagated in the instantiation of the joinStmt | ||
| 392 | // below. | ||
| 393 | std::string withName = instantiateWith(clause.getField().getTable()); | ||
| 394 | |||
| 386 | // Recursively parse the subquery, and therefore obtain an | 395 | // Recursively parse the subquery, and therefore obtain an |
| 387 | // instantiated table to join against, as well as any joins or CTEs | 396 | // instantiated table to join against, as well as any joins or CTEs |
| 388 | // that the subquery may require to function. | 397 | // that the subquery may require to function. |
| @@ -406,7 +415,6 @@ namespace verbly { | |||
| 406 | // create a non-recursive CTE that represents the through table | 415 | // create a non-recursive CTE that represents the through table |
| 407 | // joined against the subquery, then LEFT JOIN against it and | 416 | // joined against the subquery, then LEFT JOIN against it and |
| 408 | // condition on the join column being NULL as before. | 417 | // condition on the join column being NULL as before. |
| 409 | std::string withName = instantiateWith(clause.getField().getTable()); | ||
| 410 | std::string withInstName = instantiateTable(withName); | 418 | std::string withInstName = instantiateTable(withName); |
| 411 | 419 | ||
| 412 | // LEFT JOIN against the CTE. | 420 | // LEFT JOIN against the CTE. |
