mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Fixed the SQLQuery to return empty query in only certain cases
This commit is contained in:
parent
b6f88036eb
commit
73c249128b
@ -457,10 +457,6 @@ class SQLQuery {
|
|||||||
function sql() {
|
function sql() {
|
||||||
// TODO: Don't require this internal-state manipulate-and-preserve - let sqlQueryToString() handle the new syntax
|
// TODO: Don't require this internal-state manipulate-and-preserve - let sqlQueryToString() handle the new syntax
|
||||||
$origFrom = $this->from;
|
$origFrom = $this->from;
|
||||||
|
|
||||||
if(!$this->from) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build from clauses
|
// Build from clauses
|
||||||
foreach($this->from as $alias => $join) {
|
foreach($this->from as $alias => $join) {
|
||||||
@ -474,12 +470,19 @@ class SQLQuery {
|
|||||||
$this->from[$alias] = strtoupper($join['type']) . " JOIN \"{$join['table']}\" AS \"$alias\" ON $filter";
|
$this->from[$alias] = strtoupper($join['type']) . " JOIN \"{$join['table']}\" AS \"$alias\" ON $filter";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = DB::getConn()->sqlQueryToString($this);
|
$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;
|
$this->from = $origFrom;
|
||||||
|
|
||||||
|
// The query was most likely just created and then exectued.
|
||||||
|
if($sql === 'SELECT *') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user