- A lot of bugfixes, mainly with escaping (still working on it to get 100% coverage)

This commit is contained in:
mcndave committed 2021-03-15 13:42:52 +00:00
1 parent e3d0e45a4e
commit 3905047111
8 files changed
+91 -126

No files matched your search

+2 -3
View File
@@ -22,14 +22,13 @@ class Create extends Fragment {
public function render() : string
{
return $this->renderSegments([
static::SQL_TOKEN, $this->renderTables($this->table),
$this->renderFields(),
static::SQL_TOKEN, $this->renderTables($this->table), $this->renderFields(),
]);
}
public function renderFields() : string
{
return "(" . PHP_EOL . implode(",".PHP_EOL, array_map(function($field) {
return "(" . PHP_EOL . implode("," . PHP_EOL, array_map(function($field) {
return " " . EntityField::generateCreateColumn($field);
}, $this->fieldList)) . PHP_EOL . ")";
}
+11 -5
View File
@@ -9,7 +9,9 @@ class Set extends Fragment {
public int $order = 0;
public array $dataset;
public ? array $escapedFields;
public QueryBuilderInterface $queryBuilder;
public function __construct(QueryBuilderInterface $queryBuilder)
@@ -17,10 +19,11 @@ class Set extends Fragment {
$this->queryBuilder = $queryBuilder;
}
public function set(array $dataset) : self
public function set(array $dataset, ? array $escapedFields = null) : self
{
$this->dataset = $dataset;
$this->escapedFields = $escapedFields;
return $this;
}
@@ -34,10 +37,13 @@ class Set extends Fragment {
public function renderParameterPlaceholders() : string
{
$keys = [];
foreach($this->dataset as $key =>$value) {
$this->queryBuilder->addParameter($value, ":v_$key");
$keys[] = "$key=:v_$key";
$field = $this->escapedFields[$key] ?? $key;
$keys[] = "{$field}=:v_{$key}";
}
return implode(",", $keys);