Skip to content

Commit

Permalink
SqlBuilder: uses delimited table name [Closes #49]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 10, 2015
1 parent 7f77026 commit 73cd3c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Database/Table/SqlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct($tableName, Connection $connection, IReflection $ref
$this->tableName = $tableName;
$this->databaseReflection = $reflection;
$this->driver = $connection->getSupplementalDriver();
$this->delimitedTable = $this->tryDelimite($tableName);
$this->delimitedTable = implode('.', array_map(array($this->driver, 'delimite'), explode('.', $tableName)));
}


Expand All @@ -89,7 +89,7 @@ public function buildUpdateQuery()
if ($this->limit !== NULL || $this->offset) {
throw new Nette\NotSupportedException('LIMIT clause is not supported in UPDATE query.');
}
return $this->tryDelimite("UPDATE {$this->tableName} SET ?" . $this->buildConditions());
return "UPDATE {$this->delimitedTable} SET ?" . $this->tryDelimite($this->buildConditions());
}


Expand All @@ -98,7 +98,7 @@ public function buildDeleteQuery()
if ($this->limit !== NULL || $this->offset) {
throw new Nette\NotSupportedException('LIMIT clause is not supported in DELETE query.');
}
return $this->tryDelimite("DELETE FROM {$this->tableName}" . $this->buildConditions());
return "DELETE FROM {$this->delimitedTable}" . $this->tryDelimite($this->buildConditions());
}


Expand Down Expand Up @@ -139,7 +139,7 @@ public function buildSelectQuery($columns = NULL)
}

$queryJoins = $this->buildQueryJoins($joins);
$query = "{$querySelect} FROM {$this->tableName}{$queryJoins}{$queryCondition}{$queryEnd}";
$query = "{$querySelect} FROM {$this->delimitedTable}{$queryJoins}{$queryCondition}{$queryEnd}";

if ($this->limit !== NULL || $this->offset) {
$this->driver->applyLimit($query, $this->limit, $this->offset);
Expand Down

0 comments on commit 73cd3c2

Please sign in to comment.