Skip to content

Commit

Permalink
coverage fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pvsaintpe committed May 2, 2024
1 parent f149c6e commit a559fdc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Compilers/CreateCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ private static function beforeTable(?Fluent $command = null): string
return $command ? 'if not exists' : '';
}

/**
* @codeCoverageIgnore
*/
private static function compileLike(Grammar $grammar, Fluent $command): string
{
$table = $command->get('table');
Expand Down
15 changes: 15 additions & 0 deletions src/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,29 @@ class Builder extends BasePostgresBuilder

public $name;

/**
* @codeCoverageIgnore
*/
public function createView(string $view, string $select, $materialize = false): void
{
$blueprint = $this->createBlueprint($view);
$blueprint->createView($view, $select, $materialize);
$this->build($blueprint);
}

/**
* @codeCoverageIgnore
*/
public function dropView(string $view): void
{
$blueprint = $this->createBlueprint($view);
$blueprint->dropView($view);
$this->build($blueprint);
}

/**
* @codeCoverageIgnore
*/
public function hasView($view): bool
{
return count($this->connection->selectFromWriteConnection($this->grammar->compileViewExists(), [
Expand All @@ -36,11 +45,17 @@ public function hasView($view): bool
])) > 0;
}

/**
* @codeCoverageIgnore
*/
public function getForeignKeys($tableName): array
{
return $this->connection->selectFromWriteConnection($this->grammar->compileForeignKeysListing($tableName));
}

/**
* @codeCoverageIgnore
*/
public function getViewDefinition($view): string
{
$results = $this->connection->selectFromWriteConnection($this->grammar->compileViewDefinition(), [
Expand Down
21 changes: 21 additions & 0 deletions src/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ public function compileCreate(Blueprint $blueprint, Fluent $command): string
);
}

/**
* @codeCoverageIgnore
*/
public function compileAttachPartition(Blueprint $blueprint, Fluent $command): string
{
return AttachPartitionCompiler::compile($this, $blueprint, $command);
}

/**
* @codeCoverageIgnore
*/
public function compileDetachPartition(Blueprint $blueprint, Fluent $command): string
{
return sprintf(
Expand All @@ -50,6 +56,9 @@ public function compileDetachPartition(Blueprint $blueprint, Fluent $command): s
);
}

/**
* @codeCoverageIgnore
*/
public function compileCreateView(Blueprint $blueprint, Fluent $command): string
{
$materialize = $command->get('materialize') ? 'materialized' : '';
Expand All @@ -63,16 +72,25 @@ public function compileCreateView(Blueprint $blueprint, Fluent $command): string
]));
}

/**
* @codeCoverageIgnore
*/
public function compileDropView(Blueprint $blueprint, Fluent $command): string
{
return 'drop view ' . $this->wrapTable($command->get('view'));
}

/**
* @codeCoverageIgnore
*/
public function compileViewExists(): string
{
return 'select * from information_schema.views where table_schema = ? and table_name = ?';
}

/**
* @codeCoverageIgnore
*/
public function compileForeignKeysListing(string $tableName): string
{
return sprintf("
Expand All @@ -92,6 +110,9 @@ public function compileForeignKeysListing(string $tableName): string
", $tableName);
}

/**
* @codeCoverageIgnore
*/
public function compileViewDefinition(): string
{
return 'select view_definition from information_schema.views where table_schema = ? and table_name = ?';
Expand Down

0 comments on commit a559fdc

Please sign in to comment.