- Added identifier escaping to match differents PDO drivers
This commit is contained in:
1 parent
def8decb4e
commit
3ff97f3bf0
8 files changed
+71
-30
No files matched your search
+20
-6
@@ -8,7 +8,7 @@ class Repository
|
||||
{
|
||||
const DEFAULT_ALIAS = "this";
|
||||
|
||||
protected ? ConnectionAdapter $adapter;
|
||||
public ? ConnectionAdapter $adapter;
|
||||
|
||||
protected QueryBuilder $queryBuilder;
|
||||
|
||||
@@ -141,7 +141,7 @@ class Repository
|
||||
|
||||
public function insert(array $fieldlist, string $table, string $alias, ? string $schema) : self
|
||||
{
|
||||
$this->queryBuilder->insert($fieldlist, $table, $alias, $schema);
|
||||
$this->queryBuilder->insert($fieldlist, $this->escapeTable($table), $alias, $schema);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ class Repository
|
||||
|
||||
public function update(string $table, string $alias, ? string $schema) : self
|
||||
{
|
||||
$this->queryBuilder->update($table, $alias, $schema);
|
||||
$this->queryBuilder->update($this->escapeTable($table), $alias, $schema);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -176,14 +176,14 @@ class Repository
|
||||
|
||||
public function from(string $table, ? string $alias, ? string $schema) : self
|
||||
{
|
||||
$this->queryBuilder->from($table, $alias, $this->adapter->adapter()->database, $schema);
|
||||
$this->queryBuilder->from($this->escapeTable($table), $alias, $this->escapeDatabase($this->adapter->adapter()->database), $schema ? $this->escapeSchema($schema) : null);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function join(string $type, $table, $field, $value) : self
|
||||
{
|
||||
$this->queryBuilder->join($type, $table, $field, $value);
|
||||
$this->queryBuilder->join($type, $this->escapeTable($table), $field, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -470,7 +470,6 @@ class Repository
|
||||
|
||||
public function collectionFromQuery(? string $entityClass = null) : EntityCollection
|
||||
{
|
||||
|
||||
$class = $entityClass ?: $this->entityClass;
|
||||
|
||||
$entityCollection = new EntityCollection();
|
||||
@@ -556,5 +555,20 @@ class Repository
|
||||
return "REFLECT TABLE";
|
||||
}
|
||||
|
||||
public function escapeTable(string $identifier) : string
|
||||
{
|
||||
return $this->adapter->adapter()->escapeIdentifier($identifier, Adapter\AdapterInterface::IDENTIFIER_TABLE);
|
||||
}
|
||||
|
||||
public function escapeDatabase(string $identifier) : string
|
||||
{
|
||||
return $this->adapter->adapter()->escapeIdentifier($identifier, Adapter\AdapterInterface::IDENTIFIER_DATABASE);
|
||||
}
|
||||
|
||||
public function escapeSchema(string $identifier) : string
|
||||
{
|
||||
return $this->adapter->adapter()->escapeIdentifier($identifier, Adapter\AdapterInterface::IDENTIFIER_SCHEMA);
|
||||
}
|
||||
|
||||
protected function finalizeQuery() : void {}
|
||||
}
|
||||
Reference in new issue
Block a user