Class DB IO, fix for trailing ; with RETURNING

If an INSERT query has no RETURNING but ; at the end, the RETURNING was
added after the ;

The ; is now stripped before adding RETURNING
This commit is contained in:
Clemens Schwaighofer
2018-02-08 10:58:53 +09:00
parent 73cdbe27c0
commit d9df0d64b8
2 changed files with 16 additions and 11 deletions

View File

@@ -663,6 +663,8 @@
}
if (!preg_match("/ returning /i", $this->query) && $this->pk_name && $this->pk_name != 'NULL')
{
// check if this query has a ; at the end and remove it
$this->query = preg_replace("/(;\s*)$/", '', $this->query);
$this->query .= " RETURNING ".$this->pk_name;
$this->returning_id = true;
}