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
@ -458,10 +458,6 @@ class SQLQuery {
|
||||
// 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) {
|
||||
// $join can be something like this array structure
|
||||
@ -476,10 +472,17 @@ class SQLQuery {
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user