Skip to content

Commit 0ead865

Browse files
fix tests
1 parent c4ba519 commit 0ead865

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function compileTables()
8989
.'from sys.tables as t '
9090
.'join sys.partitions as p on p.object_id = t.object_id '
9191
.'join sys.allocation_units as u on u.container_id = p.hobt_id '
92-
.'group by t.name '
92+
.'group by t.name, t.schema_id '
9393
.'order by t.name';
9494
}
9595

src/Illuminate/Database/Schema/PostgresBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function dropAllTables()
7272
$qualifiedName = $table['schema'].'.'.$table['name'];
7373

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

100100
foreach ($this->getViews() as $view) {
101-
if (in_array($this->grammar->escapeNames($view['schema']), $schemas)) {
101+
if (in_array($this->grammar->escapeNames([$view['schema']])[0], $schemas)) {
102102
$views[] = $view['schema'].'.'.$view['name'];
103103
}
104104
}

tests/Database/DatabasePostgresBuilderTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ public function testDropAllTablesWhenSearchPathIsString()
244244
$processor->shouldReceive('processTables')->once()->andReturn([['name' => 'users', 'schema' => 'public']]);
245245
$connection->shouldReceive('selectFromWriteConnection')->with('sql')->andReturn([['name' => 'users', 'schema' => 'public']]);
246246
$grammar->shouldReceive('escapeNames')->with(['public'])->andReturn(['"public"']);
247-
$grammar->shouldReceive('escapeNames')->with('public')->andReturn(['"public"']);
248247
$grammar->shouldReceive('escapeNames')->with(['foo'])->andReturn(['"foo"']);
249248
$grammar->shouldReceive('escapeNames')->with(['users', 'public.users'])->andReturn(['"users"', '"public"."users"']);
250249
$grammar->shouldReceive('compileDropAllTables')->with(['public.users'])->andReturn('drop table "public"."users" cascade');
@@ -267,11 +266,11 @@ public function testDropAllTablesWhenSearchPathIsStringOfMany()
267266
$processor->shouldReceive('processTables')->once()->andReturn([['name' => 'users', 'schema' => 'foouser']]);
268267
$grammar->shouldReceive('compileTables')->andReturn('sql');
269268
$connection->shouldReceive('selectFromWriteConnection')->with('sql')->andReturn([['name' => 'users', 'schema' => 'foouser']]);
270-
$grammar->shouldReceive('escapeNames')->with(['foouser', 'public', 'foo_bar-Baz.Áüõß'])->andReturn(['"foo"']);
269+
$grammar->shouldReceive('escapeNames')->with(['foouser', 'public', 'foo_bar-Baz.Áüõß'])->andReturn(['"foouser"', '"public"', '"foo_bar-Baz"."Áüõß"']);
271270
$grammar->shouldReceive('escapeNames')->with(['foo'])->andReturn(['"foo"']);
272-
$grammar->shouldReceive('escapeNames')->with('foouser')->andReturn(['"foouser"']);
271+
$grammar->shouldReceive('escapeNames')->with(['foouser'])->andReturn(['"foouser"']);
273272
$grammar->shouldReceive('escapeNames')->with(['users', 'foouser.users'])->andReturn(['"users"', '"foouser"."users"']);
274-
$grammar->shouldReceive('compileDropAllTables')->with(['"foouser"."users"'])->andReturn('drop table "foouser"."users" cascade');
273+
$grammar->shouldReceive('compileDropAllTables')->with(['foouser.users'])->andReturn('drop table "foouser"."users" cascade');
275274
$connection->shouldReceive('statement')->with('drop table "foouser"."users" cascade');
276275
$builder = $this->getBuilder($connection);
277276

@@ -296,11 +295,11 @@ public function testDropAllTablesWhenSearchPathIsArrayOfMany()
296295
$processor->shouldReceive('processTables')->once()->andReturn([['name' => 'users', 'schema' => 'foouser']]);
297296
$grammar->shouldReceive('compileTables')->andReturn('sql');
298297
$connection->shouldReceive('selectFromWriteConnection')->with('sql')->andReturn([['name' => 'users', 'schema' => 'foouser']]);
299-
$grammar->shouldReceive('escapeNames')->with(['foouser', 'dev', 'test', 'spaced schema'])->andReturn(['"foouser"', '"dev"', '"test"', "spaced schema"]);
298+
$grammar->shouldReceive('escapeNames')->with(['foouser', 'dev', 'test', 'spaced schema'])->andReturn(['"foouser"', '"dev"', '"test"', '"spaced schema"']);
300299
$grammar->shouldReceive('escapeNames')->with(['foo'])->andReturn(['"foo"']);
301300
$grammar->shouldReceive('escapeNames')->with(['users', 'foouser.users'])->andReturn(['"users"', '"foouser"."users"']);
302-
$grammar->shouldReceive('escapeNames')->with('foouser')->andReturn(['"foouser"']);
303-
$grammar->shouldReceive('compileDropAllTables')->with(['"foouser"."users"'])->andReturn('drop table "foouser"."users" cascade');
301+
$grammar->shouldReceive('escapeNames')->with(['foouser'])->andReturn(['"foouser"']);
302+
$grammar->shouldReceive('compileDropAllTables')->with(['foouser.users'])->andReturn('drop table "foouser"."users" cascade');
304303
$connection->shouldReceive('statement')->with('drop table "foouser"."users" cascade');
305304
$builder = $this->getBuilder($connection);
306305

0 commit comments

Comments
 (0)