- Completed SQLite pragma's missing code
This commit is contained in:
parent
6c6733b503
commit
953fc35680
src
@ -57,8 +57,8 @@ class SQLite implements AdapterInterface, MigrateInterface, SqlAdapterInterface
|
||||
public function setup(array $configuration) : void
|
||||
{
|
||||
$this->path = $configuration['path'] ?? "";
|
||||
$this->pragmaBegin = $configuration['pragma_begin'] ?? [];
|
||||
$this->pragmaClose = $configuration['pragma_close'] ?? [];
|
||||
$this->pragmaBegin = array_filter($configuration['pragma_begin'] ?? []);
|
||||
$this->pragmaClose = array_filter($configuration['pragma_close'] ?? []);
|
||||
}
|
||||
|
||||
# https://sqlite.org/lang_keywords.html
|
||||
@ -187,8 +187,16 @@ class SQLite implements AdapterInterface, MigrateInterface, SqlAdapterInterface
|
||||
$builder = new QueryBuilder\SqliteQueryBuilder();
|
||||
|
||||
foreach($pragmaList as $pragma) {
|
||||
list($key, $value) = explode('=', $pragma);
|
||||
$pdo->query($builder->pragma($key, $value)->render());
|
||||
list($key, $value) = explode('=', $pragma) + [ null, null ];
|
||||
|
||||
$sql = $builder->pragma($key, $value)->render();
|
||||
$query = $pdo->query($sql);
|
||||
|
||||
if ( ! $query->execute() ) {
|
||||
throw new \InvalidArgumentException(sprintf("Pragma query could not be executed : %s", $sql));
|
||||
}
|
||||
|
||||
$builder->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Pragma extends \Ulmus\Query\Fragment {
|
||||
public function render() : string
|
||||
{
|
||||
if ( isset($this->value) ) {
|
||||
$value = sprintf($this->callable ? " (%s)" : " = %s", $this->value);
|
||||
$value = sprintf($this->callable ? " (%s)" : "=%s", $this->value);
|
||||
}
|
||||
|
||||
return $this->renderSegments([
|
||||
|
@ -144,13 +144,15 @@ class Repository
|
||||
}
|
||||
}
|
||||
|
||||
public function clone(object|array $entity) : bool
|
||||
public function clone(object|array $entity) : object|false
|
||||
{
|
||||
$entity = is_object($entity) ? clone $entity : $entity;
|
||||
|
||||
foreach(Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField() as $key => $field) {
|
||||
unset($entity->$key);
|
||||
}
|
||||
|
||||
return $this->save($entity);
|
||||
return $this->save($entity) ? $entity : false;
|
||||
}
|
||||
|
||||
public function save(object|array $entity, ? array $fieldsAndValue = null, bool $replace = false) : bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user