Merge branch 'master' of https://git.mcnd.ca/mcndave/ulmus
- Reworked the removeQueryFragment.
This commit is contained in:
commit
71de0a8ac1
|
@ -48,6 +48,7 @@ class Select extends Fragment {
|
||||||
return $this->renderSegments([
|
return $this->renderSegments([
|
||||||
( $this->union ? 'UNION' : false ),
|
( $this->union ? 'UNION' : false ),
|
||||||
static::SQL_TOKEN,
|
static::SQL_TOKEN,
|
||||||
|
( $this->distinct ? 'DISTINCT' : false ),
|
||||||
( $this->top ? sprintf('TOP (%s)', $this->top) : false ),
|
( $this->top ? sprintf('TOP (%s)', $this->top) : false ),
|
||||||
implode(', ', $this->fields)
|
implode(', ', $this->fields)
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -63,9 +63,7 @@ class Repository
|
||||||
|
|
||||||
public function count() : int
|
public function count() : int
|
||||||
{
|
{
|
||||||
if ( null !== $select = $this->queryBuilder->getFragment(Query\Select::class) ) {
|
$this->removeQueryFragment($this->queryBuilder->getFragment(Query\Select::class));
|
||||||
$this->queryBuilder->removeFragment($select);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $this->queryBuilder->getFragment(Query\GroupBy::class) ) {
|
if ( $this->queryBuilder->getFragment(Query\GroupBy::class) ) {
|
||||||
$this->select( "DISTINCT COUNT(*) OVER ()" );
|
$this->select( "DISTINCT COUNT(*) OVER ()" );
|
||||||
|
@ -271,6 +269,13 @@ class Repository
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeQueryFragment(? Query\Fragment $fragment) : self
|
||||||
|
{
|
||||||
|
$fragment && $this->queryBuilder->removeFragment($fragment);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function selectEntity(string $entity, string $alias, string $prependField = "") : self
|
public function selectEntity(string $entity, string $alias, string $prependField = "") : self
|
||||||
{
|
{
|
||||||
$prependField and ($prependField .= "$");
|
$prependField and ($prependField .= "$");
|
||||||
|
@ -280,8 +285,6 @@ class Repository
|
||||||
$this->select("$alias.$key as {$prependField}{$field['name']}");
|
$this->select("$alias.$key as {$prependField}{$field['name']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectJsonEntity(string $entity, string $alias, bool $skipFrom = false) : self
|
public function selectJsonEntity(string $entity, string $alias, bool $skipFrom = false) : self
|
||||||
|
@ -311,6 +314,14 @@ class Repository
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function distinct(/*array|Stringable*/ $fields) : self
|
||||||
|
{
|
||||||
|
$this->queryBuilder->select($fields);
|
||||||
|
$this->queryBuilder->getFragment(Query\Select::class)->distinct = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function insert(array $fieldlist, string $table, string $alias, ? string $schema) : self
|
public function insert(array $fieldlist, string $table, string $alias, ? string $schema) : self
|
||||||
{
|
{
|
||||||
$this->queryBuilder->insert($fieldlist, $this->escapeTable($table), $alias, $this->escapedDatabase(), $schema);
|
$this->queryBuilder->insert($fieldlist, $this->escapeTable($table), $alias, $this->escapedDatabase(), $schema);
|
||||||
|
|
Loading…
Reference in New Issue