- Fixed conflicts
This commit is contained in:
commit
325704260b
31 files changed
+632
-127
No files matched your search
+9
-2
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Ulmus\Query;
|
||||
|
||||
use Ulmus\Adapter\AdapterInterface;
|
||||
use Ulmus\Annotation,
|
||||
Ulmus\Common\EntityField;
|
||||
|
||||
@@ -17,7 +18,13 @@ class Alter extends Fragment {
|
||||
|
||||
public bool $skipExisting = true;
|
||||
|
||||
public array $fieldList;
|
||||
public array $fieldList;
|
||||
|
||||
public AdapterInterface $adapter;
|
||||
|
||||
public function __construct(AdapterInterface $adapter) {
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
@@ -29,7 +36,7 @@ class Alter extends Fragment {
|
||||
public function renderFields() : string
|
||||
{
|
||||
return "(" . PHP_EOL . implode("," . PHP_EOL, array_map(function($field) {
|
||||
return " " . EntityField::generateAlterColumn($field);
|
||||
return " " . EntityField::generateAlterColumn($this->adapter, $field);
|
||||
}, $this->fieldList)) . PHP_EOL . ")";
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Ulmus\Query;
|
||||
|
||||
use Ulmus\Adapter\AdapterInterface;
|
||||
use Ulmus\Annotation,
|
||||
Ulmus\Common\EntityField;
|
||||
|
||||
@@ -19,6 +20,12 @@ class Create extends Fragment {
|
||||
|
||||
public array $fieldList;
|
||||
|
||||
public AdapterInterface $adapter;
|
||||
|
||||
public function __construct(AdapterInterface $adapter) {
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
return $this->renderSegments([
|
||||
@@ -29,7 +36,7 @@ class Create extends Fragment {
|
||||
public function renderFields() : string
|
||||
{
|
||||
return "(" . PHP_EOL . implode("," . PHP_EOL, array_map(function($field) {
|
||||
return " " . EntityField::generateCreateColumn($field);
|
||||
return " " . EntityField::generateCreateColumn($this->adapter, $field);
|
||||
}, $this->fieldList)) . PHP_EOL . ")";
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,6 @@ class Select extends Fragment {
|
||||
if ( ! is_numeric($key) ) {
|
||||
$value = sprintf(static::FIELD_AS, $value, $key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->renderSegments([
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Query\Sqlite;
|
||||
|
||||
class Pragma extends \Ulmus\Query\Fragment {
|
||||
|
||||
const SQL_TOKEN = "PRAGMA %s%s";
|
||||
|
||||
public int $order = 15;
|
||||
|
||||
public /* object|string */ $pragma;
|
||||
|
||||
public $value;
|
||||
|
||||
public bool $callable;
|
||||
|
||||
public function set(/* object|Stringable */ $pragma, /* ? mixed */ $value = null, bool $callable = false) : self
|
||||
{
|
||||
$this->pragma = $pragma;
|
||||
|
||||
if ($value) {
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
$this->callable = $callable;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
if ( isset($this->value) ) {
|
||||
$value = sprintf($this->callable ? " (%s)" : " = %s", $this->value);
|
||||
}
|
||||
|
||||
return $this->renderSegments([
|
||||
sprintf(static::SQL_TOKEN, $this->pragma, $value ?? "")
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user