Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hafezdivandari committed Nov 16, 2023
1 parent c4ba519 commit 0ead865
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function compileTables()
.'from sys.tables as t '
.'join sys.partitions as p on p.object_id = t.object_id '
.'join sys.allocation_units as u on u.container_id = p.hobt_id '
.'group by t.name '
.'group by t.name, t.schema_id '
.'order by t.name';
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Schema/PostgresBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function dropAllTables()
$qualifiedName = $table['schema'].'.'.$table['name'];

if (empty(array_intersect($this->grammar->escapeNames([$table['name'], $qualifiedName]), $excludedTables))
&& in_array($this->grammar->escapeNames($table['schema']), $schemas)) {
&& in_array($this->grammar->escapeNames([$table['schema']])[0], $schemas)) {
$tables[] = $qualifiedName;
}
}
Expand All @@ -98,7 +98,7 @@ public function dropAllViews()
$schemas = $this->grammar->escapeNames($this->getSchemas());

foreach ($this->getViews() as $view) {
if (in_array($this->grammar->escapeNames($view['schema']), $schemas)) {
if (in_array($this->grammar->escapeNames([$view['schema']])[0], $schemas)) {
$views[] = $view['schema'].'.'.$view['name'];
}
}
Expand Down
13 changes: 6 additions & 7 deletions tests/Database/DatabasePostgresBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ public function testDropAllTablesWhenSearchPathIsString()
$processor->shouldReceive('processTables')->once()->andReturn([['name' => 'users', 'schema' => 'public']]);
$connection->shouldReceive('selectFromWriteConnection')->with('sql')->andReturn([['name' => 'users', 'schema' => 'public']]);
$grammar->shouldReceive('escapeNames')->with(['public'])->andReturn(['"public"']);
$grammar->shouldReceive('escapeNames')->with('public')->andReturn(['"public"']);
$grammar->shouldReceive('escapeNames')->with(['foo'])->andReturn(['"foo"']);
$grammar->shouldReceive('escapeNames')->with(['users', 'public.users'])->andReturn(['"users"', '"public"."users"']);
$grammar->shouldReceive('compileDropAllTables')->with(['public.users'])->andReturn('drop table "public"."users" cascade');
Expand All @@ -267,11 +266,11 @@ public function testDropAllTablesWhenSearchPathIsStringOfMany()
$processor->shouldReceive('processTables')->once()->andReturn([['name' => 'users', 'schema' => 'foouser']]);
$grammar->shouldReceive('compileTables')->andReturn('sql');
$connection->shouldReceive('selectFromWriteConnection')->with('sql')->andReturn([['name' => 'users', 'schema' => 'foouser']]);
$grammar->shouldReceive('escapeNames')->with(['foouser', 'public', 'foo_bar-Baz.Áüõß'])->andReturn(['"foo"']);
$grammar->shouldReceive('escapeNames')->with(['foouser', 'public', 'foo_bar-Baz.Áüõß'])->andReturn(['"foouser"', '"public"', '"foo_bar-Baz"."Áüõß"']);
$grammar->shouldReceive('escapeNames')->with(['foo'])->andReturn(['"foo"']);
$grammar->shouldReceive('escapeNames')->with('foouser')->andReturn(['"foouser"']);
$grammar->shouldReceive('escapeNames')->with(['foouser'])->andReturn(['"foouser"']);
$grammar->shouldReceive('escapeNames')->with(['users', 'foouser.users'])->andReturn(['"users"', '"foouser"."users"']);
$grammar->shouldReceive('compileDropAllTables')->with(['"foouser"."users"'])->andReturn('drop table "foouser"."users" cascade');
$grammar->shouldReceive('compileDropAllTables')->with(['foouser.users'])->andReturn('drop table "foouser"."users" cascade');
$connection->shouldReceive('statement')->with('drop table "foouser"."users" cascade');
$builder = $this->getBuilder($connection);

Expand All @@ -296,11 +295,11 @@ public function testDropAllTablesWhenSearchPathIsArrayOfMany()
$processor->shouldReceive('processTables')->once()->andReturn([['name' => 'users', 'schema' => 'foouser']]);
$grammar->shouldReceive('compileTables')->andReturn('sql');
$connection->shouldReceive('selectFromWriteConnection')->with('sql')->andReturn([['name' => 'users', 'schema' => 'foouser']]);
$grammar->shouldReceive('escapeNames')->with(['foouser', 'dev', 'test', 'spaced schema'])->andReturn(['"foouser"', '"dev"', '"test"', "spaced schema"]);
$grammar->shouldReceive('escapeNames')->with(['foouser', 'dev', 'test', 'spaced schema'])->andReturn(['"foouser"', '"dev"', '"test"', '"spaced schema"']);
$grammar->shouldReceive('escapeNames')->with(['foo'])->andReturn(['"foo"']);
$grammar->shouldReceive('escapeNames')->with(['users', 'foouser.users'])->andReturn(['"users"', '"foouser"."users"']);
$grammar->shouldReceive('escapeNames')->with('foouser')->andReturn(['"foouser"']);
$grammar->shouldReceive('compileDropAllTables')->with(['"foouser"."users"'])->andReturn('drop table "foouser"."users" cascade');
$grammar->shouldReceive('escapeNames')->with(['foouser'])->andReturn(['"foouser"']);
$grammar->shouldReceive('compileDropAllTables')->with(['foouser.users'])->andReturn('drop table "foouser"."users" cascade');
$connection->shouldReceive('statement')->with('drop table "foouser"."users" cascade');
$builder = $this->getBuilder($connection);

Expand Down

0 comments on commit 0ead865

Please sign in to comment.