- 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

+19 -8
View File
@@ -305,7 +305,7 @@ class QueryBuilder implements Query\QueryBuilderInterface
$join->outer = $outer;
$join->alias = $alias;
return $join;
}
@@ -328,7 +328,7 @@ class QueryBuilder implements Query\QueryBuilderInterface
return $this;
}
public function create(array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
public function create(Adapter\AdapterInterface $adapter, array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
{
if ( null === $this->getFragment(Query\Create::class) ) {
if ( $schema ) {
@@ -339,7 +339,7 @@ class QueryBuilder implements Query\QueryBuilderInterface
$table = "$database.$table";
}
$create = new Query\Create();
$create = new Query\Create($adapter);
$this->push($create);
$create->fieldList = $fieldlist;
@@ -352,7 +352,7 @@ class QueryBuilder implements Query\QueryBuilderInterface
return $this;
}
public function alter(array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
public function alter(Adapter\AdapterInterface $adapter, array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
{
if ( null === $this->getFragment(Query\Create::class) ) {
if ( $schema ) {
@@ -363,7 +363,7 @@ class QueryBuilder implements Query\QueryBuilderInterface
$table = "$database.$table";
}
$alter = new Query\Alter();
$alter = new Query\Alter($adapter);
$this->push($alter);
$alter->fieldList = $fieldlist;
@@ -405,7 +405,7 @@ class QueryBuilder implements Query\QueryBuilderInterface
$sql = [];
usort($this->queryStack, function($q1, $q2) {
return $q1->order <=> $q2->order;
return (float) $q1->order <=> (float) $q2->order;
});
foreach($this->queryStack as $fragment) {
@@ -456,9 +456,9 @@ class QueryBuilder implements Query\QueryBuilderInterface
}
}
public function getFragments() : array
public function getFragments(/*? Query\Fragment|array*/ $fragment = null) : array
{
return $this->queryStack;
return $fragment === null ? array_filter($this->queryStack, fn($e) => get_class($e) === $fragment) : $this->queryStack;
}
public function __toString() : string
@@ -485,4 +485,15 @@ class QueryBuilder implements Query\QueryBuilderInterface
{
$this->values = $values;
}
protected function nextJoinOrder() : float
{
$next = 0;
foreach($this->getFragments(Query\Join::class) as $join) {
$next = max($next, $join->joinOrder - Query\Join::ORDER_VALUE);
}
return $next + 1;
}
}