Skip to content

Commit

Permalink
MINOR Fixed the SQLQuery to return empty query in only certain cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Stig Lindqvist authored and Stig Lindqvist committed Sep 27, 2011
1 parent b6f8803 commit 73c2491
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions model/SQLQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,6 @@ function getFilter() {
function sql() {
// TODO: Don't require this internal-state manipulate-and-preserve - let sqlQueryToString() handle the new syntax
$origFrom = $this->from;

if(!$this->from) {
return '';
}

// Build from clauses
foreach($this->from as $alias => $join) {
Expand All @@ -474,12 +470,19 @@ function sql() {
$this->from[$alias] = strtoupper($join['type']) . " JOIN \"{$join['table']}\" AS \"$alias\" ON $filter";
}
}

$sql = DB::getConn()->sqlQueryToString($this);
if($this->replacementsOld) $sql = str_replace($this->replacementsOld, $this->replacementsNew, $sql);
if($this->replacementsOld) {
$sql = str_replace($this->replacementsOld, $this->replacementsNew, $sql);
}

$this->from = $origFrom;

// The query was most likely just created and then exectued.
if($sql === 'SELECT *') {
return '';
}

return $sql;
}

Expand Down

0 comments on commit 73c2491

Please sign in to comment.