mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
BUGFIX Allow omitting FROM clause in sqlQueryToString()
This commit is contained in:
parent
0ec8ee1335
commit
74abdec18b
@ -1554,15 +1554,13 @@ class PostgreSQLDatabase extends SS_Database {
|
|||||||
* helper function in Database?
|
* helper function in Database?
|
||||||
*/
|
*/
|
||||||
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
||||||
if (!$sqlQuery->from) return '';
|
|
||||||
$distinct = $sqlQuery->distinct ? "DISTINCT " : "";
|
$distinct = $sqlQuery->distinct ? "DISTINCT " : "";
|
||||||
if($sqlQuery->delete) {
|
if($sqlQuery->delete) {
|
||||||
$text = "DELETE ";
|
$text = "DELETE ";
|
||||||
} else if($sqlQuery->select) {
|
} else if($sqlQuery->select) {
|
||||||
$text = "SELECT $distinct" . implode(", ", $sqlQuery->select);
|
$text = "SELECT $distinct" . implode(", ", $sqlQuery->select);
|
||||||
}
|
}
|
||||||
$text .= " FROM " . implode(" ", $sqlQuery->from);
|
if($sqlQuery->from) $text .= " FROM " . implode(" ", $sqlQuery->from);
|
||||||
|
|
||||||
if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->getFilter(). ")";
|
if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->getFilter(). ")";
|
||||||
if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby);
|
if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby);
|
||||||
if($sqlQuery->having) $text .= " HAVING ( " . implode(" ) AND ( ", $sqlQuery->having) . " )";
|
if($sqlQuery->having) $text .= " HAVING ( " . implode(" ) AND ( ", $sqlQuery->having) . " )";
|
||||||
|
Loading…
Reference in New Issue
Block a user