- A lot of work done on bug fixing. Added a new SQLite adapter

This commit is contained in:
mcndave committed 2022-01-28 16:37:35 +00:00
1 parent 667df92e52
commit c14644cdda
28 files changed
+727 -234

No files matched your search

+9 -2
View File
@@ -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 . ")";
}
}
+8 -1
View File
@@ -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 . ")";
}
}
+5 -2
View File
@@ -8,7 +8,7 @@ use Ulmus\Repository\ConditionTrait;
class Join extends Fragment
{
use ConditionTrait;
const SQL_OUTER = "OUTER";
const SQL_TOKEN = "JOIN";
@@ -39,9 +39,12 @@ class Join extends Fragment
public int $order = 40;
public int $joinOrder = 0;
public function __construct(QueryBuilderInterface $queryBuilder)
{
$this->queryBuilder = new QueryBuilder();
$cls = get_class($queryBuilder);
$this->queryBuilder = new $cls();
$this->queryBuilder->parent = $queryBuilder;
}
-1
View File
@@ -42,7 +42,6 @@ class Select extends Fragment {
if ( ! is_numeric($key) ) {
$value = sprintf(static::FIELD_AS, $value, $key);
}
}
return $this->renderSegments([
+40
View File
@@ -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 ?? "")
]);
}
}