Use separator in limit1

This commit is contained in:
Jakub Vrana
2018-02-01 18:53:53 +01:00
parent 0866c79afb
commit 685bf29abc
7 changed files with 15 additions and 14 deletions

View File

@@ -226,10 +226,10 @@ if (isset($_GET["pgsql"])) {
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
}
function limit1($table, $query, $where) {
function limit1($table, $query, $where, $separator = "\n") {
return (preg_match('~^INTO~', $query)
? limit($query, $where, 1)
: " $query WHERE ctid = (SELECT ctid FROM " . table($table) . "$where LIMIT 1)"
? limit($query, $where, 1, 0, $separator)
: " $query WHERE ctid = (SELECT ctid FROM " . table($table) . $where . $separator . "LIMIT 1)"
);
}